Metadata-Version: 1.0
Name: whatthepatch
Version: 0.0.2
Summary: A patch parsing library
Home-page: https://github.com/cscorley/whatthepatch
Author: Christopher S. Corley
Author-email: cscorley@ua.edu
License: Copyright (c) 2012 The Board of Trustees of The University of Alabama
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

 1. Redistributions of source code must retain the above copyright
    notice, this list of conditions and the following disclaimer.
 2. Redistributions in binary form must reproduce the above copyright
    notice, this list of conditions and the following disclaimer in the
    documentation and/or other materials provided with the distribution.
 3. Neither the name of the University nor the names of the contributors
    may be used to endorse or promote products derived from this software
    without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.

Description: What The Patch!?
        ================
        
        What The Patch!? is a Python 2 library for parsing patch files.
        It's only purpose is to read a patch file and get it into some
        usable form by other programs.
        
        Features
        ---------
        
        - Parsing of almost all ``diff`` formats (except forwarded ed):
        
          - normal (default, --normal)
          - copied context (-c, --context)
          - unified context (-u, --unified)
          - ed script (-e, --ed)
          - rcs ed script (-n, --rcs)
        
        - Parsing of several SCM patches:
        
          - CVS
          - SVN
          - Git
        
        Installation
        ------------
        
        To install What The Patch!?, simply:
        
        .. code-block:: bash
        
            $ pip install whatthepatch
        
        Usage
        =====
        
        Let us say we have a patch file containing some changes, aptly named
        'somechanges.patch':
        
        .. code-block:: diff
        
            --- lao	2012-12-26 23:16:54.000000000 -0600
            +++ tzu	2012-12-26 23:16:50.000000000 -0600
            @@ -1,7 +1,6 @@
            -The Way that can be told of is not the eternal Way;
            -The name that can be named is not the eternal name.
             The Nameless is the origin of Heaven and Earth;
            -The Named is the mother of all things.
            +The named is the mother of all things.
            +
             Therefore let there always be non-being,
               so we may see their subtlety,
              And let there always be being,
            @@ -9,3 +8,6 @@
             The two are the same,
             But after they are produced,
               they have different names.
            +They both may be called deep and profound.
            +Deeper and more profound,
            +The door of all subtleties!
        
        
        Parsing
        -------
        
        Here is how we would use What The Patch!? in Python to get the changeset for each diff in the patch:
        
        .. code-block:: python
        
            >>> import whatthepatch
            >>> with open('somechanges.patch') as f:
            ...     text = f.read()
            ...
            >>> for diff in whatthepatch.parse_patch(text):
            ...     print(diff)
            ...
            diff(header=header(index_path=None,
                            old_path='lao',
                            old_version='2012-12-26 23:16:54.000000000 -0600',
                            new_path='tzu',
                            new_version='2012-12-26 23:16:50.000000000 -0600'
                            ),
                changes=[
                (1, None,   'The Way that can be told of is not the eternal Way;'),
                (2, None,   'The name that can be named is not the eternal name.'),
                (3, 1,      'The Nameless is the origin of Heaven and Earth;'),
                (4, None,   'The Named is the mother of all things.'),
                (None, 2,   'The named is the mother of all things.'),
                (None, 3,   ''),
                (5, 4,       'Therefore let there always be non-being,'),
                (6, 5,      '  so we may see their subtlety,'),
                (7, 6,      'And let there always be being,'),
                (9, 8,      'The two are the same,'),
                (10, 9,     'But after they are produced,'),
                (11, 10,    '  they have different names.'),
                (None, 11,  'They both may be called deep and profound.'),
                (None, 12,  'Deeper and more profound,'),
                (None, 13,  'The door of all subtleties!')
                ]
                )
        
        *Edited to show structure of the results*
        
        The changes are listed as they are in the patch, but instead of the +/- syntax
        of the patch, we get a tuple of two numbers and the text of the line.
        What these numbers indicate are as follows:
        
        #. ``( 1, None, ... )`` indicates line 1 of the file lao was **removed**.
        #. ``( None, 2, ... )`` indicates line 2 of the file tzu was **inserted**.
        #. ``( 5, 4, ... )`` indicates that line 5 of lao and line 4 of tzu are **equal**.
        
        Please note that not all patch formats provide the actual lines modified, so some 
        results will have the text portion of the tuple set to ``None``.
        
        Applying
        --------
        
        To apply a diff to some lines of text, first read the patch and parse it.
        
        .. code-block:: python
        
            >>> import whatthepatch
            >>> with open('somechanges.patch') as f:
            ...     text = f.read()
            ...
            >>> with open('lao') as f:
            ...     lao = f.read()
            ...
            >>> diff = [x for x in whatthepatch.parse_patch(text)]
            >>> diff = diff[0]
            >>> tzu = whatthepatch.apply_diff(diff, lao)
        
        
        Contribute
        ==========
        
        #. Fork this repository
        #. Create a new branch to work on
        #. Commit your tests and/or changes
        #. Push and create a pull request here!
        
        
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Operating System :: OS Independent
Classifier: License :: OSI Approved :: BSD License
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Version Control
Classifier: Topic :: Text Processing
