Browse Source

Apply lib2to3.fixes.tuple_params, and provied sensible names and docs.

Gary van der Merwe 11 years ago
parent
commit
55124a5ea8
4 changed files with 22 additions and 13 deletions
  1. 8 2
      dulwich/objects.py
  2. 2 1
      dulwich/pack.py
  3. 10 9
      dulwich/patch.py
  4. 2 1
      dulwich/tests/compat/server_utils.py

+ 8 - 2
dulwich/objects.py

@@ -804,8 +804,14 @@ def sorted_tree_items(entries, name_order):
         yield TreeEntry(name, mode, hexsha)
 
 
-def cmp_entry((name1, value1), (name2, value2)):
-    """Compare two tree entries in tree order."""
+def cmp_entry(entry1, entry2):
+    """Compare two tree entries in tree order.
+
+    :param entry1: (name, value) tuple
+    :param entry2: (name, value) tuple
+    """
+    (name1, value1) = entry1
+    (name2, value2) = entry2
     if stat.S_ISDIR(value1[0]):
         name1 += "/"
     if stat.S_ISDIR(value2[0]):

+ 2 - 1
dulwich/pack.py

@@ -719,8 +719,9 @@ def unpack_object(read_all, read_some=None, compute_crc32=False,
     return unpacked, unused
 
 
-def _compute_object_size((num, obj)):
+def _compute_object_size(value):
     """Compute the size of a unresolved object for use with LRUSizeCache."""
+    (num, obj) = value
     if num in DELTA_TYPES:
         return chunks_length(obj[1])
     return chunks_length(obj)

+ 10 - 9
dulwich/patch.py

@@ -114,20 +114,20 @@ def is_binary(content):
     return '\0' in content[:FIRST_FEW_BYTES]
 
 
-def write_object_diff(f, store, (old_path, old_mode, old_id),
-                                (new_path, new_mode, new_id),
-                                diff_binary=False):
+def write_object_diff(f, store, old_file, new_file, diff_binary=False):
     """Write the diff for an object.
 
     :param f: File-like object to write to
     :param store: Store to retrieve objects from, if necessary
-    :param (old_path, old_mode, old_hexsha): Old file
-    :param (new_path, new_mode, new_hexsha): New file
+    :param old_file: (path, mode, hexsha) tuple
+    :param new_file: (path, mode, hexsha) tuple
     :param diff_binary: Whether to diff files even if they
         are considered binary files by is_binary().
 
     :note: the tuple elements should be None for nonexistant files
     """
+    (old_path, old_mode, old_id) = old_file
+    (new_path, new_mode, new_id) = new_file
     def shortid(hexsha):
         if hexsha is None:
             return "0" * 7
@@ -177,16 +177,17 @@ def write_object_diff(f, store, (old_path, old_mode, old_id),
             old_path, new_path))
 
 
-def write_blob_diff(f, (old_path, old_mode, old_blob),
-                       (new_path, new_mode, new_blob)):
+def write_blob_diff(f, old_file, new_file):
     """Write diff file header.
 
     :param f: File-like object to write to
-    :param (old_path, old_mode, old_blob): Previous file (None if nonexisting)
-    :param (new_path, new_mode, new_blob): New file (None if nonexisting)
+    :param old_file: (path, mode, hexsha) tuple (None if nonexisting)
+    :param new_file: (path, mode, hexsha) tuple (None if nonexisting)
 
     :note: The use of write_object_diff is recommended over this function.
     """
+    (old_path, old_mode, old_blob) = old_file
+    (new_path, new_mode, new_blob) = new_file
     def blob_id(blob):
         if blob is None:
             return "0" * 7

+ 2 - 1
dulwich/tests/compat/server_utils.py

@@ -325,8 +325,9 @@ class NoSideBand64kReceivePackHandler(ReceivePackHandler):
                      if c != 'side-band-64k')
 
 
-def ignore_error((e_type, e_value, e_tb)):
+def ignore_error(error):
     """Check whether this error is safe to ignore."""
+    (e_type, e_value, e_tb) = error
     return (issubclass(e_type, socket.error) and
             e_value[0] in (errno.ECONNRESET, errno.EPIPE))