More docstrings.
authorJelmer Vernooij <jelmer@samba.org>
Fri, 8 May 2009 17:01:25 +0000 (19:01 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 8 May 2009 17:01:25 +0000 (19:01 +0200)
dulwich/index.py
dulwich/object_store.py
dulwich/server.py

index af441c21f2f6c9e0dc3345aabd20dd0accae9405..61da545427e4fc1bcfd0564de02511a4197eef05 100644 (file)
@@ -24,10 +24,12 @@ from dulwich.objects import sha_to_hex, hex_to_sha
 
 
 def read_cache_time(f):
+    """Read a cache time."""
     return struct.unpack(">LL", f.read(8))
 
 
 def write_cache_time(f, t):
+    """Write a cache time."""
     if isinstance(t, int):
         t = (t, 0)
     f.write(struct.pack(">LL", *t))
@@ -119,13 +121,19 @@ def write_index_dict(f, entries):
 
 
 class Index(object):
+    """A Git Index file."""
 
     def __init__(self, filename):
+        """Open an index file.
+        
+        :param filename: Path to the index file
+        """
         self._filename = filename
         self.clear()
         self.read()
 
     def write(self):
+        """Write current contents of index to disk."""
         f = open(self._filename, 'w')
         try:
             write_index_dict(f, self._byname)
@@ -133,6 +141,7 @@ class Index(object):
             f.close()
 
     def read(self):
+        """Read current contents of index from disk."""
         f = open(self._filename, 'r')
         try:
             for x in read_index(f):
@@ -141,18 +150,23 @@ class Index(object):
             f.close()
 
     def __len__(self):
+        """Number of entries in this index file."""
         return len(self._byname)
 
     def __getitem__(self, name):
+        """Retrieve entry by relative path."""
         return self._byname[name]
 
     def __iter__(self):
+        """Iterate over the paths in this index."""
         return iter(self._byname)
 
     def get_sha1(self, path):
+        """Return the (git object) SHA1 for the object at a path."""
         return self[path][-2]
 
     def clear(self):
+        """Remove all contents from this index."""
         self._byname = {}
 
     def __setitem__(self, name, x):
index d0076dc014b342fff34ae375383dd25c187f1be3..39ee67ff4484cd6467802f67931989ea85d56899 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Git object store interfaces and implementation."""
+
+
 import itertools
 import os
 import tempfile
index d54db1ac5c61947da5f3da6fda18ee52e78fdc01..678bd9696706a3cd347721ba4563952a06131687 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Git smart network protocol server implementation."""
+
+
 import SocketServer
 import tempfile
 
@@ -88,6 +92,7 @@ class GitBackend(Backend):
 
 
 class Handler(object):
+    """Smart protocol command handler base class."""
 
     def __init__(self, backend, read, write):
         self.backend = backend
@@ -98,6 +103,7 @@ class Handler(object):
 
 
 class UploadPackHandler(Handler):
+    """Protocol handler for uploading a pack to the server."""
 
     def default_capabilities(self):
         return ("multi_ack", "side-band-64k", "thin-pack", "ofs-delta")
@@ -170,6 +176,7 @@ class UploadPackHandler(Handler):
 
 
 class ReceivePackHandler(Handler):
+    """Protocol handler for downloading a pack to the client."""
 
     def default_capabilities(self):
         return ("report-status", "delete-refs")