Browse Source

Add more docstrings.

Jelmer Vernooij 16 năm trước cách đây
mục cha
commit
678c78a8b2

+ 26 - 0
dulwich/repo.py

@@ -18,8 +18,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
 """Repository access."""
 
+
 import os
 import stat
 
@@ -50,6 +52,11 @@ INDEX_FILENAME = "index"
 
 
 def follow_ref(container, name):
+    """Follow a ref back to a SHA1.
+    
+    :param container: Ref container to use for looking up refs.
+    :param name: Name of the original ref.
+    """
     contents = container[name]
     if contents.startswith(SYMREF):
         ref = contents[len(SYMREF):]
@@ -61,14 +68,25 @@ def follow_ref(container, name):
 
 
 class RefsContainer(object):
+    """A container for refs."""
 
     def as_dict(self, base):
+        """Return the contents of this ref container under base as a dict."""
         raise NotImplementedError(self.as_dict)
 
     def follow(self, name):
+        """Follow a ref name back to a SHA1.
+        
+        :param name: Name of the ref
+        """
         return follow_ref(self, name)
 
     def set_ref(self, name, other):
+        """Make a ref point at another ref.
+
+        :param name: Name of the ref to set
+        :param other: Name of the ref to point at
+        """
         self[name] = "ref: %s\n" % other
 
     def import_refs(self, base, other):
@@ -77,6 +95,7 @@ class RefsContainer(object):
 
 
 class DiskRefsContainer(RefsContainer):
+    """Refs container that reads refs from disk."""
 
     def __init__(self, path):
         self.path = path
@@ -85,6 +104,7 @@ class DiskRefsContainer(RefsContainer):
         return "%s(%r)" % (self.__class__.__name__, self.path)
 
     def keys(self, base=None):
+        """Refs present in this container."""
         return list(self.iterkeys(base))
 
     def iterkeys(self, base=None):
@@ -110,6 +130,9 @@ class DiskRefsContainer(RefsContainer):
                 yield ("%s/%s" % (dir, filename)).strip("/")
 
     def as_dict(self, base=None, follow=True):
+        """Return the contents of this container as a dictionary.
+
+        """
         ret = {}
         if base is None:
             keys = self.iterkeys()
@@ -127,6 +150,9 @@ class DiskRefsContainer(RefsContainer):
         return ret
 
     def refpath(self, name):
+        """Return the disk path of a ref.
+
+        """
         if os.path.sep != "/":
             name = name.replace("/", os.path.sep)
         return os.path.join(self.path, name)

+ 1 - 0
dulwich/tests/__init__.py

@@ -17,3 +17,4 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+"""Tests for Dulwich."""

+ 4 - 0
dulwich/tests/test_index.py

@@ -16,6 +16,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for the index."""
+
+
 import os
 import stat
 from unittest import TestCase

+ 4 - 0
dulwich/tests/test_object_store.py

@@ -16,6 +16,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for the object store interface."""
+
+
 from unittest import TestCase
 
 from dulwich.object_store import (

+ 4 - 0
dulwich/tests/test_objects.py

@@ -17,6 +17,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for git base objects."""
+
+
 import os
 import stat
 import unittest

+ 4 - 0
dulwich/tests/test_pack.py

@@ -17,6 +17,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for Dulwich packs."""
+
+
 import os
 import unittest
 

+ 4 - 0
dulwich/tests/test_protocol.py

@@ -16,6 +16,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for the smart protocol utility functions."""
+
+
 from cStringIO import StringIO
 from unittest import TestCase
 

+ 4 - 0
dulwich/tests/test_repository.py

@@ -17,6 +17,10 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
+
+"""Tests for the repository."""
+
+
 import os
 import unittest