patchutils.py: Remove is_binary() function.

This commit is contained in:
Sebastian Lackner 2016-04-02 23:13:01 +02:00
parent a3ecf01ce2
commit f21f134546
2 changed files with 7 additions and 10 deletions

View File

@ -314,7 +314,7 @@ def contains_binary_patch(all_patches, indices, filename):
"""Checks if any patch with given indices affecting filename is a binary patch."""
for i in indices:
for patch in all_patches[i].patches:
if patch.modified_file == filename and patch.is_binary():
if patch.modified_file == filename and patch.is_binary:
return True
return False

View File

@ -65,7 +65,7 @@ class PatchObject(object):
self.filename = filename
self.offset_begin = None
self.offset_end = None
self.isbinary = False
self.is_binary = False
self.oldname = None
self.newname = None
@ -75,9 +75,6 @@ class PatchObject(object):
self.newsha1 = None
self.newmode = None
def is_binary(self):
return self.isbinary
def read_chunks(self):
"""Iterates over arbitrary sized chunks of this patch."""
assert self.offset_end >= self.offset_begin
@ -276,7 +273,7 @@ def _read_single_patch(fp, header, oldname=None, newname=None):
if line is None: raise PatchParserError("Unexpected end of file.")
r = re.match("^(literal|delta) ([0-9]+)", line)
if not r: raise NotImplementedError("Only literal/delta patches are supported.")
patch.isbinary = True
patch.is_binary = True
# Skip over patch data
while True:
@ -787,7 +784,7 @@ if __name__ == "__main__":
self.assertEqual(patches[0].signed_off_by, [("Author Name", "author@email.com"),
("Other Developer", "other@email.com")])
self.assertEqual(patches[0].filename, patchfile.name)
self.assertEqual(patches[0].isbinary, False)
self.assertEqual(patches[0].is_binary, False)
self.assertEqual(patches[0].modified_file, "test.txt")
lines = patches[0].read().rstrip("\n").split("\n")
@ -808,7 +805,7 @@ if __name__ == "__main__":
self.assertEqual(patches[0].patch_revision, 1)
self.assertEqual(patches[0].signed_off_by, [])
self.assertEqual(patches[0].filename, patchfile.name)
self.assertEqual(patches[0].isbinary, False)
self.assertEqual(patches[0].is_binary, False)
self.assertEqual(patches[0].modified_file, "test.txt")
lines = patches[0].read().rstrip("\n").split("\n")
@ -829,7 +826,7 @@ if __name__ == "__main__":
self.assertEqual(patches[0].patch_revision, 1)
self.assertEqual(patches[0].signed_off_by, [])
self.assertEqual(patches[0].filename, patchfile.name)
self.assertEqual(patches[0].isbinary, False)
self.assertEqual(patches[0].is_binary, False)
self.assertEqual(patches[0].modified_file, "test.txt")
del expected[0:2]
@ -845,7 +842,7 @@ if __name__ == "__main__":
self.assertEqual(patches[0].patch_revision, 1)
self.assertEqual(patches[0].signed_off_by, [])
self.assertEqual(patches[0].filename, "unknown.patch")
self.assertEqual(patches[0].isbinary, False)
self.assertEqual(patches[0].is_binary, False)
self.assertEqual(patches[0].modified_file, "test.txt")
# Basic tests for apply_patch()