/usr/lib/python2.7/dist-packages/xxdiff/patches.py is in xxdiff-scripts 1:4.0.1+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | # This file is part of the xxdiff package. See xxdiff for license and details.
"""
Functions to manipulate patches.
"""
__author__ = 'Martin Blais <blais@furius.ca>'
# stdlib imports.
import re
def splitpatch(text):
"""
Split output in chunks starting with ^Index. Returns a list of pairs
(tuples), each with (filename, patch) contents.
"""
## splitre = re.compile('^Index: (.*)$', re.M)
splitre = re.compile('^Index: (.*)$', re.M)
chunks = []
curbeg, curfn = None, None
for mo in splitre.finditer(text):
if curbeg != None:
assert curfn
chunks.append( (curfn, text[curbeg:mo.start()]) )
curbeg = mo.start()
curfn = mo.group(1)
if curbeg != None:
chunks.append( (curfn, text[curbeg:]) )
return chunks
|