{ "info": { "author": "Christopher S. Corley", "author_email": "cscorley@crimson.ua.edu", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "Intended Audience :: Science/Research", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Software Development :: Version Control", "Topic :: Text Processing" ], "description": "What The Patch!?\n================\n\n.. image:: https://travis-ci.org/cscorley/whatthepatch.svg?style=flat\n :target: https://travis-ci.org/cscorley/whatthepatch\n\nWhat The Patch!? is a library for both parsing and applying patch files.\n\nFeatures\n---------\n\n- Parsing of almost all ``diff`` formats (except forwarded ed):\n\n - normal (default, --normal)\n - copied context (-c, --context)\n - unified context (-u, --unified)\n - ed script (-e, --ed)\n - rcs ed script (-n, --rcs)\n\n- Parsing of several SCM patches:\n\n - CVS\n - SVN\n - Git\n\nInstallation\n------------\n\nTo install What The Patch!?, simply:\n\n.. code-block:: bash\n\n $ pip install whatthepatch\n\nUsage\n=====\n\nLet us say we have a patch file containing some changes, aptly named\n'somechanges.patch':\n\n.. code-block:: diff\n\n --- lao\t2012-12-26 23:16:54.000000000 -0600\n +++ tzu\t2012-12-26 23:16:50.000000000 -0600\n @@ -1,7 +1,6 @@\n -The Way that can be told of is not the eternal Way;\n -The name that can be named is not the eternal name.\n The Nameless is the origin of Heaven and Earth;\n -The Named is the mother of all things.\n +The named is the mother of all things.\n +\n Therefore let there always be non-being,\n so we may see their subtlety,\n And let there always be being,\n @@ -9,3 +8,6 @@\n The two are the same,\n But after they are produced,\n they have different names.\n +They both may be called deep and profound.\n +Deeper and more profound,\n +The door of all subtleties!\n\n\nParsing\n-------\n\nHere is how we would use What The Patch!? in Python to get the changeset for\neach diff in the patch:\n\n.. code-block:: python\n\n >>> import whatthepatch\n >>> import pprint\n >>> with open('tests/casefiles/diff-unified.diff') as f:\n ... text = f.read()\n ...\n >>> for diff in whatthepatch.parse_patch(text):\n ... print(diff) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE\n ...\n diff(header=header(index_path=None,\n old_path='lao',\n old_version='2013-01-05 16:56:19.000000000 -0600',\n new_path='tzu',\n new_version='2013-01-05 16:56:35.000000000 -0600'),\n changes=[Change(old=1, new=None, line='The Way that can be told of is not the eternal Way;', hunk=1),\n Change(old=2, new=None, line='The name that can be named is not the eternal name.', hunk=1),\n Change(old=3, new=1, line='The Nameless is the origin of Heaven and Earth;', hunk=1),\n Change(old=4, new=None, line='The Named is the mother of all things.', hunk=1),\n Change(old=None, new=2, line='The named is the mother of all things.', hunk=1),\n Change(old=None, new=3, line='', hunk=1),\n Change(old=5, new=4, line='Therefore let there always be non-being,', hunk=1),\n Change(old=6, new=5, line=' so we may see their subtlety,', hunk=1),\n Change(old=7, new=6, line='And let there always be being,', hunk=1),\n Change(old=9, new=8, line='The two are the same,', hunk=2),\n Change(old=10, new=9, line='But after they are produced,', hunk=2),\n Change(old=11, new=10, line=' they have different names.', hunk=2),\n Change(old=None, new=11, line='They both may be called deep and profound.', hunk=2),\n Change(old=None, new=12, line='Deeper and more profound,', hunk=2),\n Change(old=None, new=13, line='The door of all subtleties!', hunk=2)],\n text='...')\n\nThe changes are listed as they are in the patch, but instead of the +/- syntax\nof the patch, we get a tuple of two numbers and the text of the line.\nWhat these numbers indicate are as follows:\n\n#. ``( old=1, new=None, ... )`` indicates line 1 of the file lao was **removed**.\n#. ``( old=None, new=2, ... )`` indicates line 2 of the file tzu was **inserted**.\n#. ``( old=5, new=4, ... )`` indicates that line 5 of lao and line 4 of tzu are **equal**.\n\nPlease note that not all patch formats provide the actual lines modified, so some\nresults will have the text portion of the tuple set to ``None``.\n\nApplying\n--------\n\nTo apply a diff to some lines of text, first read the patch and parse it.\n\n.. code-block:: python\n\n >>> import whatthepatch\n >>> with open('tests/casefiles/diff-default.diff') as f:\n ... text = f.read()\n ...\n >>> with open('tests/casefiles/lao') as f:\n ... lao = f.read()\n ...\n >>> diff = [x for x in whatthepatch.parse_patch(text)]\n >>> diff = diff[0]\n >>> tzu = whatthepatch.apply_diff(diff, lao)\n >>> tzu # doctest: +NORMALIZE_WHITESPACE\n ['The Nameless is the origin of Heaven and Earth;',\n 'The named is the mother of all things.',\n '',\n 'Therefore let there always be non-being,',\n ' so we may see their subtlety,',\n 'And let there always be being,',\n ' so we may see their outcome.',\n 'The two are the same,',\n 'But after they are produced,',\n ' they have different names.',\n 'They both may be called deep and profound.',\n 'Deeper and more profound,',\n 'The door of all subtleties!']\n\n\nContribute\n==========\n\n#. Fork this repository\n#. Create a new branch to work on\n#. Commit your tests and/or changes\n#. Push and create a pull request here!\n\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cscorley/whatthepatch", "keywords": "patch,diff,parser", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "whatthepatch", "package_url": "https://pypi.org/project/whatthepatch/", "platform": "", "project_url": "https://pypi.org/project/whatthepatch/", "project_urls": { "Homepage": "https://github.com/cscorley/whatthepatch" }, "release_url": "https://pypi.org/project/whatthepatch/0.0.6/", "requires_dist": null, "requires_python": "", "summary": "A patch parsing and application library.", "version": "0.0.6" }, "last_serial": 5561393, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "153512d9d9873945b8e13c1c2699d9fc", "sha256": "6611c736feabce08cb0dc157cd2f25cbe2c962fc6b51ebd7e915253fdc0c84a7" }, "downloads": -1, "filename": "whatthepatch-0.0.1.macosx-10.8-intel.exe", "has_sig": false, "md5_digest": "153512d9d9873945b8e13c1c2699d9fc", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 68256, "upload_time": "2012-12-27T01:50:21", "url": "https://files.pythonhosted.org/packages/03/23/fb78a3d223960a86f611ba69c01a0ffeaae513d739bce0bd7d60e9284def/whatthepatch-0.0.1.macosx-10.8-intel.exe" }, { "comment_text": "", "digests": { "md5": "0d71c612f494b9c6a7694490819a731d", "sha256": "4690ab4a01fee9abb06047d60466c206a3f71d99d43c41e84c56751cc20177c6" }, "downloads": -1, "filename": "whatthepatch-0.0.1.tar.gz", "has_sig": false, "md5_digest": "0d71c612f494b9c6a7694490819a731d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6621, "upload_time": "2012-12-27T01:50:18", "url": "https://files.pythonhosted.org/packages/7b/cc/212304357044e29f61f2ca3648d1ebc33587e9bce73f1a7aa361d826f0b6/whatthepatch-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "bf1804c375292ec45c79659d199d8835", "sha256": "c2f95cbdc3d6cdc6dd0073e7f8f3465bc74f12ad49d4d4514efdc3d0f79c2533" }, "downloads": -1, "filename": "whatthepatch-0.0.2.macosx-10.8-intel.exe", "has_sig": false, "md5_digest": "bf1804c375292ec45c79659d199d8835", "packagetype": "bdist_wininst", "python_version": "any", "requires_python": null, "size": 75669, "upload_time": "2013-01-16T05:18:57", "url": "https://files.pythonhosted.org/packages/bc/3e/6bd39564289b5704669f2b7b8bc2b209c1feefbfeca2e3c5717fe9761da1/whatthepatch-0.0.2.macosx-10.8-intel.exe" }, { "comment_text": "", "digests": { "md5": "15b06cc2ac96218115e36cfac6bc1337", "sha256": "9365f92e33e6627efb4c4a391169fb87c32f38b1587168bea8bb122f18aba72f" }, "downloads": -1, "filename": "whatthepatch-0.0.2.tar.gz", "has_sig": false, "md5_digest": "15b06cc2ac96218115e36cfac6bc1337", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11169, "upload_time": "2013-01-16T05:18:54", "url": "https://files.pythonhosted.org/packages/95/d4/44ac4cbd52fa162213842fb36dc518685e69421da3972d2f129bd1c983b8/whatthepatch-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "fbf359655181851898a0cd432688c9a4", "sha256": "3d424c496d0dda607547e603d5cabb4f11264980ea71c531689441d9d24bb578" }, "downloads": -1, "filename": "whatthepatch-0.0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fbf359655181851898a0cd432688c9a4", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12755, "upload_time": "2014-12-25T17:25:02", "url": "https://files.pythonhosted.org/packages/c5/58/3fb49d25e1388fe7abbdb23cd9742e875a0ba357c4ec53fd2caa05bd7b06/whatthepatch-0.0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ed1e41c266e0349c9f31c0aca6a2bb41", "sha256": "82574c9f635b38ffe7969bbad52b48318aa17896fecc9fbaffb5729c4e41a669" }, "downloads": -1, "filename": "whatthepatch-0.0.3.tar.gz", "has_sig": false, "md5_digest": "ed1e41c266e0349c9f31c0aca6a2bb41", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11494, "upload_time": "2014-12-25T17:24:57", "url": "https://files.pythonhosted.org/packages/7e/ce/61e47487bd71d5f897af5183944463389722b6d174a408dd488cb7f60d30/whatthepatch-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "9b2d53534b8bc4128d56019be4bf0c53", "sha256": "3112815ed7c5e4d5dd77add7fa0b9f84b2792ac57bc1b8998f4e544344512e30" }, "downloads": -1, "filename": "whatthepatch-0.0.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9b2d53534b8bc4128d56019be4bf0c53", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12031, "upload_time": "2015-12-25T23:54:36", "url": "https://files.pythonhosted.org/packages/fd/72/09a9ba36f9a77ec136d60f78676d2e91bb2656314f91910e8041b15ededf/whatthepatch-0.0.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "ff400ca6240e8b5cf9011d08152fd9ad", "sha256": "091cc0111e9361b2ba1925eef41b4b3aeeb83f19b06ff031870f75a4423d0de0" }, "downloads": -1, "filename": "whatthepatch-0.0.4.tar.gz", "has_sig": false, "md5_digest": "ff400ca6240e8b5cf9011d08152fd9ad", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11327, "upload_time": "2015-12-25T23:54:30", "url": "https://files.pythonhosted.org/packages/12/a1/4b8a0cb58402a790ceda78ef4af9614e164979675bd052230d6326af1b0e/whatthepatch-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "ba766f093ceaad883a803f16557e4975", "sha256": "6af6366e746b0f9aaf7c6dfb4668deab6e4491115a0fbf5c2897312a77c31cbc" }, "downloads": -1, "filename": "whatthepatch-0.0.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ba766f093ceaad883a803f16557e4975", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 12128, "upload_time": "2016-12-25T17:18:41", "url": "https://files.pythonhosted.org/packages/48/1f/ac27810a6b5c2cec2caa268d83290d6ed95f85ad6a6907f739f672499686/whatthepatch-0.0.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "80d7c24de99ca9501f07b42e88d6f7c1", "sha256": "494a2ec6c05b80f9ed1bd773f5ac9411298e1af6f0385f179840b5d60d001aa6" }, "downloads": -1, "filename": "whatthepatch-0.0.5.tar.gz", "has_sig": false, "md5_digest": "80d7c24de99ca9501f07b42e88d6f7c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11414, "upload_time": "2016-12-25T17:18:33", "url": "https://files.pythonhosted.org/packages/64/1e/7a63cba8a0d70245b9ab1c03694dabe36476fa65ee546e6dff6c8660434c/whatthepatch-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "86604a91dfa5e6eb5727d98dc33f36e2", "sha256": "5b3f847a8f6f9520faf01f1ed6d145a33fa0e72befbd37c946f0eb33222de0d4" }, "downloads": -1, "filename": "whatthepatch-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "86604a91dfa5e6eb5727d98dc33f36e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11301, "upload_time": "2019-07-20T19:53:18", "url": "https://files.pythonhosted.org/packages/d7/14/8e39bac4a1e5fd7c61aa89b3d8669f53694746c2465da7c1472c47213fea/whatthepatch-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "947fe97c8f50a19c01542b2ebfd57ed4", "sha256": "e11d242ef5c6d3e0e4416da244d317f1b1fa55e6d9040c313d0e18f00708b5b8" }, "downloads": -1, "filename": "whatthepatch-0.0.6.tar.gz", "has_sig": false, "md5_digest": "947fe97c8f50a19c01542b2ebfd57ed4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12502, "upload_time": "2019-07-20T19:53:19", "url": "https://files.pythonhosted.org/packages/9a/85/3e37314b88203066f5b72e565c57a55718d9e0b1af0fcf79582c47877d8f/whatthepatch-0.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "86604a91dfa5e6eb5727d98dc33f36e2", "sha256": "5b3f847a8f6f9520faf01f1ed6d145a33fa0e72befbd37c946f0eb33222de0d4" }, "downloads": -1, "filename": "whatthepatch-0.0.6-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "86604a91dfa5e6eb5727d98dc33f36e2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 11301, "upload_time": "2019-07-20T19:53:18", "url": "https://files.pythonhosted.org/packages/d7/14/8e39bac4a1e5fd7c61aa89b3d8669f53694746c2465da7c1472c47213fea/whatthepatch-0.0.6-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "947fe97c8f50a19c01542b2ebfd57ed4", "sha256": "e11d242ef5c6d3e0e4416da244d317f1b1fa55e6d9040c313d0e18f00708b5b8" }, "downloads": -1, "filename": "whatthepatch-0.0.6.tar.gz", "has_sig": false, "md5_digest": "947fe97c8f50a19c01542b2ebfd57ed4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12502, "upload_time": "2019-07-20T19:53:19", "url": "https://files.pythonhosted.org/packages/9a/85/3e37314b88203066f5b72e565c57a55718d9e0b1af0fcf79582c47877d8f/whatthepatch-0.0.6.tar.gz" } ] }