Fix formatting issues.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 9 Mar 2009 17:54:18 +0000 (17:54 +0000)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 9 Mar 2009 17:54:18 +0000 (17:54 +0000)
16 files changed:
dulwich/__init__.py
dulwich/client.py
dulwich/errors.py
dulwich/index.py
dulwich/misc.py
dulwich/object_store.py
dulwich/objects.py
dulwich/pack.py
dulwich/protocol.py
dulwich/repo.py
dulwich/server.py
dulwich/tests/__init__.py
dulwich/tests/test_index.py
dulwich/tests/test_object_store.py
dulwich/tests/test_objects.py
dulwich/tests/test_pack.py

index 6b73dd62ee7876007efe53e3488c8b5498b89553..24807af03f94b47aff0a33a3117fa5a593a0f89f 100644 (file)
@@ -1,5 +1,6 @@
 # __init__.py -- The git module of dulwich
 # Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
+# Copyright (C) 2008 Jelmer Vernooji <jelmer@samba.org>
 # 
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
index 80b2dd7ff23f1994ea7d0ce206e18a036a0546b3..4e7095e09b390849397ef62c1850b31c69e02273 100644 (file)
@@ -20,8 +20,15 @@ import os
 import select
 import socket
 import subprocess
-from dulwich.protocol import Protocol, TCP_GIT_PORT, extract_capabilities
-from dulwich.pack import write_pack_data
+
+from dulwich.protocol import (
+    Protocol,
+    TCP_GIT_PORT,
+    extract_capabilities,
+    )
+from dulwich.pack import (
+    write_pack_data,
+    )
 
 class SimpleFetchGraphWalker(object):
 
index 4066f667e9036c7fe3f95fbffc44a056ef4ee5b2..93c106e727684847a112333ede74da6852cb6c22 100644 (file)
@@ -16,6 +16,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+"""Dulwich-related exception classes and utility functions."""
+
 class WrongObjectException(Exception):
     """Baseclass for all the _ is not a _ exceptions on objects.
   
@@ -29,21 +31,25 @@ class WrongObjectException(Exception):
         string = "%s is not a %s" % (sha, self._type)
         Exception.__init__(self, string)
 
+
 class NotCommitError(WrongObjectException):
     """Indicates that the sha requested does not point to a commit."""
   
     _type = 'commit'
 
+
 class NotTreeError(WrongObjectException):
     """Indicates that the sha requested does not point to a tree."""
   
     _type = 'tree'
 
+
 class NotBlobError(WrongObjectException):
     """Indicates that the sha requested does not point to a blob."""
   
     _type = 'blob'
 
+
 class MissingCommitError(Exception):
     """Indicates that a commit was not found in the repository"""
   
index 3349cd66092ca61079cd2f7df3110e0d6aa47847..bdabfcfa0135470e74f8b367c4b4d5e7021c094f 100644 (file)
@@ -23,9 +23,11 @@ import struct
 def read_cache_time(f):
     return struct.unpack(">LL", f.read(8))
 
+
 def write_cache_time(f, t):
     f.write(struct.pack(">LL", *t))
 
+
 def read_cache_entry(f):
     beginoffset = f.tell()
     ctime = read_cache_time(f)
index d8216c02fecf6e3176ca2ecbb9b454642c2e6400..55c7602065f4ee271d73b187d06358513e371b6a 100644 (file)
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
-'''Misc utilities to work with python2.4.
+"""Misc utilities to work with python2.4.
 
 These utilities can all be deleted when dulwich decides it wants to stop
 support for python 2.4.
-'''
+"""
 try:
     import hashlib
 except ImportError:
@@ -28,7 +28,7 @@ import struct
 
 
 class defaultdict(dict):
-    '''A python 2.4 equivalent of collections.defaultdict.'''
+    """A python 2.4 equivalent of collections.defaultdict."""
 
     def __init__(self, default_factory=None, *a, **kw):
         if (default_factory is not None and
@@ -72,7 +72,7 @@ class defaultdict(dict):
 
 
 def make_sha(source=''):
-    '''A python2.4 workaround for the sha/hashlib module fiasco.'''
+    """A python2.4 workaround for the sha/hashlib module fiasco."""
     try:
         return hashlib.sha1(source)
     except NameError:
@@ -81,7 +81,7 @@ def make_sha(source=''):
 
 
 def unpack_from(fmt, buf, offset=0):
-    '''A python2.4 workaround for struct missing unpack_from.'''
+    """A python2.4 workaround for struct missing unpack_from."""
     try:
         return struct.unpack_from(fmt, buf, offset)
     except AttributeError:
index 13b453ce63279c5fb55ba8897314d47c885e008f..79c93ba3bb4632b237c92387ab695f625799727e 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-from dulwich.objects import (
-        hex_to_sha,
-        sha_to_hex,
-        ShaFile,
-        )
-from dulwich.pack import (
-        iter_sha1, 
-        load_packs, 
-        write_pack,
-        write_pack_data,
-        write_pack_index_v2,
-        PackData, 
-        )
-
 import os
 import tempfile
 import urllib2
 
+from dulwich.objects import (
+    hex_to_sha,
+    sha_to_hex,
+    ShaFile,
+    )
+from dulwich.pack import (
+    iter_sha1, 
+    load_packs, 
+    write_pack,
+    write_pack_data,
+    write_pack_index_v2,
+    PackData, 
+    )
+
 PACKDIR = 'pack'
 
 class ObjectStore(object):
index dfc703a76199ca56db8324d4d6e1dfab857d5e08..e7a6818c4ff2f419aae9069e3ad71d66c298d076 100644 (file)
@@ -25,10 +25,11 @@ import os
 import sha
 import zlib
 
-from errors import (NotCommitError,
-                    NotTreeError,
-                    NotBlobError,
-                    )
+from dulwich.errors import (
+    NotBlobError,
+    NotCommitError,
+    NotTreeError,
+    )
 
 BLOB_ID = "blob"
 TAG_ID = "tag"
index fda8874ddd0227b18ac4e103929dc6ea581f74d9..2ebfca2612624c19b6fccc3d0e8c779bf3be7a17 100644 (file)
@@ -42,18 +42,18 @@ import struct
 try:
     from struct import unpack_from
 except ImportError:
-    from misc import unpack_from
+    from dulwich.misc import unpack_from
 import sys
 import zlib
 import difflib
 
-from objects import (
-        ShaFile,
-        hex_to_sha,
-        sha_to_hex,
-        )
-from errors import ApplyDeltaError
-from misc import make_sha
+from dulwich.objects import (
+    ShaFile,
+    hex_to_sha,
+    sha_to_hex,
+    )
+from dulwich.errors import ApplyDeltaError
+from dulwich.misc import make_sha
 
 supports_mmap_offset = (sys.version_info[0] >= 3 or
         (sys.version_info[0] == 2 and sys.version_info[1] >= 6))
@@ -419,6 +419,7 @@ class PackData(object):
         return self._num_objects
   
     def calculate_checksum(self):
+        """Calculate the checksum for this pack."""
         f = open(self._filename, 'rb')
         try:
             map = simple_mmap(f, 0, self._size)
index ee9ec86677c382e14a396bfeba18b997d100dea2..34053b7bdc6bb8e504431159cd91432a90aeb172 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-from errors import HangupException, GitProtocolError
+"""Generic functions for talking the git smart server protocol."""
+
 import socket
 
+from dulwich.errors import (
+    HangupException,
+    GitProtocolError,
+    )
+
 TCP_GIT_PORT = 9418
 
 class ProtocolFile(object):
@@ -122,6 +128,12 @@ class Protocol(object):
 
 
 def extract_capabilities(text):
+    """Extract a capabilities list from a string, if present.
+
+    :param text: String to extract from
+    :return: Tuple with text with capabilities removed and list of 
+        capabilities or None (if no capabilities were present.
+    """
     if not "\0" in text:
         return text, None
     capabilities = text.split("\0")
index cb4e5f928ba666f07173c6258f777f0baeb9ae3d..b91455bee684dd26d96580575310ff8918837fc2 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-import os, stat
-
-from commit import Commit
-from errors import (
-        MissingCommitError, 
-        NotBlobError, 
-        NotCommitError, 
-        NotGitRepository,
-        NotTreeError, 
-        )
-from object_store import ObjectStore
-from objects import (
-        ShaFile,
-        Commit,
-        Tag,
-        Tree,
-        Blob,
-        )
+import os
+import stat
+
+from dulwich.errors import (
+    MissingCommitError, 
+    NotBlobError, 
+    NotCommitError, 
+    NotGitRepository,
+    NotTreeError, 
+    )
+from dulwich.object_store import ObjectStore
+from dulwich.objects import (
+    Blob,
+    Commit,
+    ShaFile,
+    Tag,
+    Tree,
+    )
 
 OBJECTDIR = 'objects'
 SYMREF = 'ref: '
index bd74eb981befe71a2cfa650cdf5f76663771026d..70d0da21b4e5b33b90fb65af82723163e617eb59 100644 (file)
 # MA  02110-1301, USA.
 
 import SocketServer
-from dulwich.protocol import Protocol, ProtocolFile, TCP_GIT_PORT, extract_capabilities
-from dulwich.repo import Repo
-from dulwich.pack import write_pack_data
 import tempfile
 
+from dulwich.protocol import (
+    Protocol,
+    ProtocolFile,
+    TCP_GIT_PORT,
+    extract_capabilities,
+    )
+from dulwich.repo import (
+    Repo,
+    )
+from dulwich.pack import (
+    write_pack_data,
+    )
+
 class Backend(object):
 
     def get_refs(self):
index abf20343e47174f56190ceb7880cdf44738fd7ea..1f5af10c2fc5e66e97bde2c657016586f52f0e4a 100644 (file)
 # MA  02110-1301, USA.
 
 import unittest
-import test_objects
-import test_repository
-import test_pack
+
+from dulwich.tests import (
+    test_objects,
+    test_repository,
+    test_pack,
+    )
 
 def test_suite():
     test_modules = [test_objects, test_repository, test_pack]
index 589effccbcadff7a1a3abb8cca7c2f015606eb7c..855ab844e5cdf12848bbf28b3e4bd6103a98fd94 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-from dulwich.index import Index, write_index
 import os
 from unittest import TestCase
 
+from dulwich.index import (
+    Index,
+    write_index,
+    )
+
 class IndexTestCase(TestCase):
 
     datadir = os.path.join(os.path.dirname(__file__), 'data/indexes')
index 97312e314e7b6713af6f237552a6c80db55b48cf..619efe02c5e4775ac3c3139d4de7e777dbef4e57 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-from dulwich.object_store import ObjectStore
 from unittest import TestCase
 
+from dulwich.object_store import ObjectStore
+
 class ObjectStoreTests(TestCase):
 
     def test_pack_dir(self):
index 7d3c4ada72edbaa32c92bc80a5e8ccf759246b67..64b58d155626847a40221c57615dbade579a52d0 100644 (file)
 import os
 import unittest
 
-from dulwich.objects import (Blob,
-                         Tree,
-                         Commit,
-                         Tag
-                         )
+from dulwich.objects import (
+    Blob,
+    Tree,
+    Commit,
+    Tag,
+    )
 
 a_sha = '6f670c0fb53f9463760b7295fbb814e965fb20c8'
 b_sha = '2969be3e8ee1c0222396a5611407e4769f14e54b'
index d185a2b6393900d80f2f8b173db5694ac025e22e..ed629ebc98cd042ba2a1dabc634300659d1b432a 100644 (file)
@@ -21,21 +21,21 @@ import os
 import unittest
 
 from dulwich.objects import (
-        Tree,
-        )
+    Tree,
+    )
 from dulwich.pack import (
-        Pack,
-        PackIndex,
-        PackData,
-        hex_to_sha,
-        sha_to_hex,
-        write_pack_index_v1,
-        write_pack_index_v2,
-        write_pack,
-        apply_delta,
-        create_delta,
-        read_zlib,
-        )
+    Pack,
+    PackIndex,
+    PackData,
+    apply_delta,
+    create_delta,
+    hex_to_sha,
+    read_zlib,
+    sha_to_hex,
+    write_pack_index_v1,
+    write_pack_index_v2,
+    write_pack,
+    )
 
 pack1_sha = 'bc63ddad95e7321ee734ea11a7a62d314e0d7481'