Ver código fonte

Some restructuredText fixes.

Jelmer Vernooij 14 anos atrás
pai
commit
2a89fff246
7 arquivos alterados com 23 adições e 25 exclusões
  1. 1 1
      dulwich/client.py
  2. 3 5
      dulwich/file.py
  3. 4 4
      dulwich/objects.py
  4. 7 6
      dulwich/pack.py
  5. 4 5
      dulwich/repo.py
  6. 3 3
      dulwich/server.py
  7. 1 1
      dulwich/web.py

+ 1 - 1
dulwich/client.py

@@ -262,7 +262,7 @@ class GitClient(object):
 def can_read(f):
     """Check if a file descriptor is readable.
 
-    :args f: either the number of the file descriptor or a file-like
+    :param f: either the number of the file descriptor or a file-like
              object which returns the fileno when f.fileno() is called.
     """
     return len(select.select([f], [], [], 0)[0]) > 0

+ 3 - 5
dulwich/file.py

@@ -16,10 +16,8 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-
 """Safe access to git files."""
 
-
 import errno
 import os
 import tempfile
@@ -65,7 +63,9 @@ def fancy_rename(oldname, newname):
 def GitFile(filename, mode='r', bufsize=-1):
     """Create a file object that obeys the git file locking protocol.
 
-    See _GitFile for a description of the file locking protocol.
+    :return: a builtin file object or a _GitFile object
+
+    :note: See _GitFile for a description of the file locking protocol.
 
     Only read-only and write-only (binary) modes are supported; r+, w+, and a
     are not.  To read and write from the same file, you can take advantage of
@@ -86,8 +86,6 @@ def GitFile(filename, mode='r', bufsize=-1):
     Traceback (most recent call last):
         ...
     OSError: [Errno 17] File exists: 'filename.lock'
-
-    :return: a builtin file object or a _GitFile object
     """
     if 'a' in mode:
         raise IOError('append mode not supported for Git files')

+ 4 - 4
dulwich/objects.py

@@ -530,9 +530,9 @@ def _parse_tag_or_commit(text):
     """Parse tag or commit text.
 
     :param text: the raw text of the tag or commit object.
-    :yield: tuples of (field, value), one per header line, in the order read
-        from the text, possibly including duplicates. Includes a field named
-        None for the freeform tag/commit text.
+    :return: iterator of tuples of (field, value), one per header line, in the
+        order read from the text, possibly including duplicates. Includes a
+        field named None for the freeform tag/commit text.
     """
     f = StringIO(text)
     for l in f:
@@ -677,7 +677,7 @@ def parse_tree(text):
     """Parse a tree text.
 
     :param text: Serialized text to parse
-    :yields: tuples of (name, mode, sha)
+    :return: iterator of tuples of (name, mode, sha)
     """
     count = 0
     l = len(text)

+ 7 - 6
dulwich/pack.py

@@ -310,7 +310,8 @@ class PackIndex(object):
     def iterentries(self):
         """Iterate over the entries in this pack index.
 
-        :yields: tuples with object name, offset in packfile and crc32 checksum.
+        :return: iterator over tuples with object name, offset in packfile and
+            crc32 checksum.
         """
         for i in range(len(self)):
             yield self._unpack_entry(i)
@@ -787,9 +788,9 @@ class PackData(object):
     def iterentries(self, progress=None):
         """Yield entries summarizing the contents of this pack.
 
-        :param progress: Progress function, called with current and total object
-            count.
-        :yields: tuples with (sha, offset, crc32)
+        :param progress: Progress function, called with current and total
+            object count.
+        :return: iterator of tuples with (sha, offset, crc32)
         """
         for offset, type, obj, crc32 in self.iterobjects(progress=progress):
             assert isinstance(offset, int)
@@ -801,8 +802,8 @@ class PackData(object):
     def sorted_entries(self, progress=None):
         """Return entries in this pack, sorted by SHA.
 
-        :param progress: Progress function, called with current and total object
-            count
+        :param progress: Progress function, called with current and total
+            object count
         :return: List of tuples with (sha, offset, crc32)
         """
         ret = list(self.iterentries(progress=progress))

+ 4 - 5
dulwich/repo.py

@@ -675,9 +675,8 @@ def _split_ref_line(line):
 def read_packed_refs(f):
     """Read a packed refs file.
 
-    Yields tuples with SHA1s and ref names.
-
     :param f: file-like object to read from
+    :return: Iterator over tuples with SHA1s and ref names.
     """
     for l in f:
         if l[0] == "#":
@@ -777,7 +776,7 @@ class BaseRepo(object):
         """Write a file to the control dir with the given name and contents.
 
         :param path: The path to the file, relative to the control dir.
-        :contents: A string to write to the file.
+        :param contents: A string to write to the file.
         """
         raise NotImplementedError(self._put_named_file)
 
@@ -1094,7 +1093,7 @@ class Repo(BaseRepo):
         """Write a file to the control dir with the given name and contents.
 
         :param path: The path to the file, relative to the control dir.
-        :contents: A string to write to the file.
+        :param contents: A string to write to the file.
         """
         path = path.lstrip(os.path.sep)
         f = GitFile(os.path.join(self.controldir(), path), 'wb')
@@ -1210,7 +1209,7 @@ class MemoryRepo(BaseRepo):
         """Write a file to the control dir with the given name and contents.
 
         :param path: The path to the file, relative to the control dir.
-        :contents: A string to write to the file.
+        :param contents: A string to write to the file.
         """
         self._named_files[path] = contents
 

+ 3 - 3
dulwich/server.py

@@ -16,13 +16,13 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.
 
-
 """Git smart network protocol server implementation.
 
 For more detailed implementation on the network protocol, see the
 Documentation/technical directory in the cgit distribution, and in particular:
-    Documentation/technical/protocol-capabilities.txt
-    Documentation/technical/pack-protocol.txt
+
+* Documentation/technical/protocol-capabilities.txt
+* Documentation/technical/pack-protocol.txt
 """
 
 

+ 1 - 1
dulwich/web.py

@@ -85,7 +85,7 @@ def send_file(req, f, content_type):
     :param req: The HTTPGitRequest object to send output to.
     :param f: An open file-like object to send; will be closed.
     :param content_type: The MIME type for the file.
-    :yield: The contents of the file.
+    :return: Iterator over the contents of the file, as chunks.
     """
     if f is None:
         yield req.not_found('File not found')