@@ -3,18 +3,22 @@ Unidiff
33
44Simple Python library to parse and interact with unified diff data.
55
6- [ ![ Build Status ] ( https://travis-ci.org/matiasb/python-unidiff.png ?branch=master )] ( https://travis-ci.org/matiasb/python-unidiff )
7-
6+ .. image :: https://travis-ci.org/matiasb/python-unidiff.svg ?branch=master
7+ :target: https://travis-ci.org/matiasb/python-unidiff
88
99Installing unidiff
1010------------------
1111
12+ ::
13+
1214 $ pip install unidiff
1315
1416
1517Quick start
1618-----------
1719
20+ ::
21+
1822 >>> import urllib2
1923 >>> from unidiff import PatchSet
2024 >>> diff = urllib2.urlopen('https://github.com/matiasb/python-unidiff/pull/3.diff')
@@ -41,11 +45,11 @@ Quick start
4145 >>> print patch[2]
4246 --- a/unidiff/utils.py
4347 +++ b/unidiff/utils.py
44- @@ -37,4 +37,3 @@
48+ @@ -37,4 +37,3 @@
4549 # - deleted line
4650 # \ No newline case (ignore)
4751 RE_HUNK_BODY_LINE = re.compile(r'^([- \+\\])')
48- -
52+
4953
5054Load unified diff data by instantiating PatchSet with a file-like object as
5155argument, or using PatchSet.from_filename class method to read diff from file.
@@ -63,6 +67,8 @@ As a quick example of what can be done, check bin/unidiff file.
6367Also, once installed, unidiff provides a command-line program that displays
6468information from diff data (a file, or stdin). For example:
6569
70+ ::
71+
6672 $ git diff | unidiff
6773 Summary
6874 -------
@@ -77,13 +83,17 @@ Load a local diff file
7783
7884To instantiate PatchSet from a local file, you can use:
7985
86+ ::
87+
8088 >>> from unidiff import PatchSet
8189 >>> patch = PatchSet.from_filename('tests/samples/bzr.diff', encoding='utf-8')
8290 >>> patch
8391 <PatchSet: [<PatchedFile: added_file>, <PatchedFile: modified_file>, <PatchedFile: removed_file>]>
8492
8593Notice the (optional) encoding parameter. If not specified, unicode input will be expected. Or alternatively:
8694
95+ ::
96+
8797 >>> import codecs
8898 >>> from unidiff import PatchSet
8999 >>> with codecs.open('tests/samples/bzr.diff', 'r', encoding='utf-8') as diff:
@@ -94,6 +104,8 @@ Notice the (optional) encoding parameter. If not specified, unicode input will b
94104
95105Finally, you can also instantiate PatchSet passing any iterable (and encoding, if needed):
96106
107+ ::
108+
97109 >>> from unidiff import PatchSet
98110 >>> with open('tests/samples/bzr.diff', 'r') as diff:
99111 ... data = diff.readlines()
@@ -106,5 +118,5 @@ Finally, you can also instantiate PatchSet passing any iterable (and encoding, i
106118References
107119----------
108120
109- * http://en.wikipedia.org/wiki/Diff_utility
110- * http://www.artima.com/weblogs/viewpost.jsp?thread=164293
121+ * http://en.wikipedia.org/wiki/Diff_utility
122+ * http://www.artima.com/weblogs/viewpost.jsp?thread=164293
0 commit comments