瀏覽代碼

Initial work migrating docstrings to google style.

Jelmer Vernooij 5 年之前
父節點
當前提交
9a402c53d1
共有 3 個文件被更改,包括 322 次插入203 次删除
  1. 7 5
      dulwich/archive.py
  2. 285 181
      dulwich/client.py
  3. 30 17
      dulwich/config.py

+ 7 - 5
dulwich/archive.py

@@ -75,12 +75,14 @@ def tar_stream(store, tree, mtime, prefix=b'', format=''):
     pieces (bytestrings). To obtain the complete .tar.gz binary file, simply
     pieces (bytestrings). To obtain the complete .tar.gz binary file, simply
     concatenate these chunks.
     concatenate these chunks.
 
 
-    :param store: Object store to retrieve objects from
-    :param tree: Tree object for the tree root
-    :param mtime: UNIX timestamp that is assigned as the modification time for
+    Args:
+      store: Object store to retrieve objects from
+      tree: Tree object for the tree root
+      mtime: UNIX timestamp that is assigned as the modification time for
         all files, and the gzip header modification time if format='gz'
         all files, and the gzip header modification time if format='gz'
-    :param format: Optional compression format for tarball
-    :return: Bytestrings
+      format: Optional compression format for tarball
+    Returns:
+      Bytestrings
     """
     """
     buf = BytesIO()
     buf = BytesIO()
     with closing(tarfile.open(None, "w:%s" % format, buf)) as tar:
     with closing(tarfile.open(None, "w:%s" % format, buf)) as tar:

+ 285 - 181
dulwich/client.py

@@ -121,12 +121,14 @@ class InvalidWants(Exception):
 
 
 
 
 def _fileno_can_read(fileno):
 def _fileno_can_read(fileno):
-    """Check if a file descriptor is readable."""
+    """Check if a file descriptor is readable.
+    """
     return len(select.select([fileno], [], [], 0)[0]) > 0
     return len(select.select([fileno], [], [], 0)[0]) > 0
 
 
 
 
 def _win32_peek_avail(handle):
 def _win32_peek_avail(handle):
-    """Wrapper around PeekNamedPipe to check how many bytes are available."""
+    """Wrapper around PeekNamedPipe to check how many bytes are available.
+    """
     from ctypes import byref, wintypes, windll
     from ctypes import byref, wintypes, windll
     c_avail = wintypes.DWORD()
     c_avail = wintypes.DWORD()
     c_message = wintypes.DWORD()
     c_message = wintypes.DWORD()
@@ -146,8 +148,7 @@ RECEIVE_CAPABILITIES = [CAPABILITY_REPORT_STATUS] + COMMON_CAPABILITIES
 
 
 
 
 class ReportStatusParser(object):
 class ReportStatusParser(object):
-    """Handle status as reported by servers with 'report-status' capability.
-    """
+    """Handle status as reported by servers with 'report-status' capability."""
 
 
     def __init__(self):
     def __init__(self):
         self._done = False
         self._done = False
@@ -158,8 +159,9 @@ class ReportStatusParser(object):
     def check(self):
     def check(self):
         """Check if there were any errors and, if so, raise exceptions.
         """Check if there were any errors and, if so, raise exceptions.
 
 
-        :raise SendPackError: Raised when the server could not unpack
-        :raise UpdateRefsError: Raised when refs could not be updated
+        Raises:
+          SendPackError: Raised when the server could not unpack
+          UpdateRefsError: Raised when refs could not be updated
         """
         """
         if self._pack_status not in (b'unpack ok', None):
         if self._pack_status not in (b'unpack ok', None):
             raise SendPackError(self._pack_status)
             raise SendPackError(self._pack_status)
@@ -187,8 +189,9 @@ class ReportStatusParser(object):
     def handle_packet(self, pkt):
     def handle_packet(self, pkt):
         """Handle a packet.
         """Handle a packet.
 
 
-        :raise GitProtocolError: Raised when packets are received after a
-            flush packet.
+        Raises:
+          GitProtocolError: Raised when packets are received after a flush
+          packet.
         """
         """
         if self._done:
         if self._done:
             raise GitProtocolError("received more data after status report")
             raise GitProtocolError("received more data after status report")
@@ -226,9 +229,10 @@ def read_pkt_refs(proto):
 class FetchPackResult(object):
 class FetchPackResult(object):
     """Result of a fetch-pack operation.
     """Result of a fetch-pack operation.
 
 
-    :var refs: Dictionary with all remote refs
-    :var symrefs: Dictionary with remote symrefs
-    :var agent: User agent string
+    Attributes:
+      refs: Dictionary with all remote refs
+      symrefs: Dictionary with remote symrefs
+      agent: User agent string
     """
     """
 
 
     _FORWARDED_ATTRS = [
     _FORWARDED_ATTRS = [
@@ -304,15 +308,14 @@ def _read_shallow_updates(proto):
 # support some capabilities. This should work properly with servers
 # support some capabilities. This should work properly with servers
 # that don't support multi_ack.
 # that don't support multi_ack.
 class GitClient(object):
 class GitClient(object):
-    """Git smart server client.
-
-    """
+    """Git smart server client."""
 
 
     def __init__(self, thin_packs=True, report_activity=None, quiet=False):
     def __init__(self, thin_packs=True, report_activity=None, quiet=False):
         """Create a new GitClient instance.
         """Create a new GitClient instance.
 
 
-        :param thin_packs: Whether or not thin packs should be retrieved
-        :param report_activity: Optional callback for reporting transport
+        Args:
+          thin_packs: Whether or not thin packs should be retrieved
+          report_activity: Optional callback for reporting transport
             activity.
             activity.
         """
         """
         self._report_activity = report_activity
         self._report_activity = report_activity
@@ -329,8 +332,12 @@ class GitClient(object):
     def get_url(self, path):
     def get_url(self, path):
         """Retrieves full url to given path.
         """Retrieves full url to given path.
 
 
-        :param path: Repository path (as string)
-        :return: Url to path (as string)
+        Args:
+          path: Repository path (as string)
+
+        Returns:
+          Url to path (as string)
+
         """
         """
         raise NotImplementedError(self.get_url)
         raise NotImplementedError(self.get_url)
 
 
@@ -338,8 +345,11 @@ class GitClient(object):
     def from_parsedurl(cls, parsedurl, **kwargs):
     def from_parsedurl(cls, parsedurl, **kwargs):
         """Create an instance of this client from a urlparse.parsed object.
         """Create an instance of this client from a urlparse.parsed object.
 
 
-        :param parsedurl: Result of urlparse.urlparse()
-        :return: A `GitClient` object
+        Args:
+          parsedurl: Result of urlparse.urlparse()
+
+        Returns:
+          A `GitClient` object
         """
         """
         raise NotImplementedError(cls.from_parsedurl)
         raise NotImplementedError(cls.from_parsedurl)
 
 
@@ -347,19 +357,24 @@ class GitClient(object):
                   progress=None):
                   progress=None):
         """Upload a pack to a remote repository.
         """Upload a pack to a remote repository.
 
 
-        :param path: Repository path (as bytestring)
-        :param update_refs: Function to determine changes to remote refs.
-            Receive dict with existing remote refs, returns dict with
+        Args:
+          path: Repository path (as bytestring)
+          update_refs: Function to determine changes to remote refs. Receive
+            dict with existing remote refs, returns dict with
             changed refs (name -> sha, where sha=ZERO_SHA for deletions)
             changed refs (name -> sha, where sha=ZERO_SHA for deletions)
-        :param generate_pack_data: Function that can return a tuple
+          generate_pack_data: Function that can return a tuple
             with number of objects and list of pack data to include
             with number of objects and list of pack data to include
-        :param progress: Optional progress function
+          progress: Optional progress function
 
 
-        :raises SendPackError: if server rejects the pack data
-        :raises UpdateRefsError: if the server supports report-status
-                                 and rejects ref updates
-        :return: new_refs dictionary containing the changes that were made
+        Returns:
+          new_refs dictionary containing the changes that were made
             {refname: new_ref}, including deleted refs.
             {refname: new_ref}, including deleted refs.
+
+        Raises:
+          SendPackError: if server rejects the pack data
+          UpdateRefsError: if the server supports report-status
+                         and rejects ref updates
+
         """
         """
         raise NotImplementedError(self.send_pack)
         raise NotImplementedError(self.send_pack)
 
 
@@ -367,14 +382,18 @@ class GitClient(object):
               depth=None):
               depth=None):
         """Fetch into a target repository.
         """Fetch into a target repository.
 
 
-        :param path: Path to fetch from (as bytestring)
-        :param target: Target repository to fetch into
-        :param determine_wants: Optional function to determine what refs
-            to fetch. Receives dictionary of name->sha, should return
+        Args:
+          path: Path to fetch from (as bytestring)
+          target: Target repository to fetch into
+          determine_wants: Optional function to determine what refs to fetch.
+            Receives dictionary of name->sha, should return
             list of shas to fetch. Defaults to all shas.
             list of shas to fetch. Defaults to all shas.
-        :param progress: Optional progress function
-        :param depth: Depth to fetch at
-        :return: Dictionary with all remote refs (not just those fetched)
+          progress: Optional progress function
+          depth: Depth to fetch at
+
+        Returns:
+          Dictionary with all remote refs (not just those fetched)
+
         """
         """
         if determine_wants is None:
         if determine_wants is None:
             determine_wants = target.object_store.determine_wants_all
             determine_wants = target.object_store.determine_wants_all
@@ -408,22 +427,30 @@ class GitClient(object):
                    progress=None, depth=None):
                    progress=None, depth=None):
         """Retrieve a pack from a git smart server.
         """Retrieve a pack from a git smart server.
 
 
-        :param path: Remote path to fetch from
-        :param determine_wants: Function determine what refs
-            to fetch. Receives dictionary of name->sha, should return
-            list of shas to fetch.
-        :param graph_walker: Object with next() and ack().
-        :param pack_data: Callback called for each bit of data in the pack
-        :param progress: Callback for progress reports (strings)
-        :param depth: Shallow fetch depth
-        :return: FetchPackResult object
+        Args:
+          path: Remote path to fetch from
+          determine_wants: Function determine what refs
+        to fetch. Receives dictionary of name->sha, should return
+        list of shas to fetch.
+          graph_walker: Object with next() and ack().
+          pack_data: Callback called for each bit of data in the pack
+          progress: Callback for progress reports (strings)
+          depth: Shallow fetch depth
+
+        Returns:
+          FetchPackResult object
+
         """
         """
         raise NotImplementedError(self.fetch_pack)
         raise NotImplementedError(self.fetch_pack)
 
 
     def get_refs(self, path):
     def get_refs(self, path):
         """Retrieve the current refs from a git smart server.
         """Retrieve the current refs from a git smart server.
 
 
-        :param path: Path to the repo to fetch from. (as bytestring)
+        Args:
+          path: Path to the repo to fetch from. (as bytestring)
+
+        Returns:
+
         """
         """
         raise NotImplementedError(self.get_refs)
         raise NotImplementedError(self.get_refs)
 
 
@@ -469,8 +496,9 @@ class GitClient(object):
 
 
         This requires the side-band-64k capability.
         This requires the side-band-64k capability.
 
 
-        :param proto: Protocol object to read from
-        :param channel_callbacks: Dictionary mapping channels to packet
+        Args:
+          proto: Protocol object to read from
+          channel_callbacks: Dictionary mapping channels to packet
             handlers to use. None for a callback discards channel data.
             handlers to use. None for a callback discards channel data.
         """
         """
         for pkt in proto.read_pkt_seq():
         for pkt in proto.read_pkt_seq():
@@ -488,11 +516,15 @@ class GitClient(object):
                                   new_refs):
                                   new_refs):
         """Handle the head of a 'git-receive-pack' request.
         """Handle the head of a 'git-receive-pack' request.
 
 
-        :param proto: Protocol object to read from
-        :param capabilities: List of negotiated capabilities
-        :param old_refs: Old refs, as received from the server
-        :param new_refs: Refs to change
-        :return: (have, want) tuple
+        Args:
+          proto: Protocol object to read from
+          capabilities: List of negotiated capabilities
+          old_refs: Old refs, as received from the server
+          new_refs: Refs to change
+
+        Returns:
+          have, want) tuple
+
         """
         """
         want = []
         want = []
         have = [x for x in old_refs.values() if not x == ZERO_SHA]
         have = [x for x in old_refs.values() if not x == ZERO_SHA]
@@ -536,9 +568,13 @@ class GitClient(object):
     def _handle_receive_pack_tail(self, proto, capabilities, progress=None):
     def _handle_receive_pack_tail(self, proto, capabilities, progress=None):
         """Handle the tail of a 'git-receive-pack' request.
         """Handle the tail of a 'git-receive-pack' request.
 
 
-        :param proto: Protocol object to read from
-        :param capabilities: List of negotiated capabilities
-        :param progress: Optional progress reporting function
+        Args:
+          proto: Protocol object to read from
+          capabilities: List of negotiated capabilities
+          progress: Optional progress reporting function
+
+        Returns:
+
         """
         """
         if CAPABILITY_SIDE_BAND_64K in capabilities:
         if CAPABILITY_SIDE_BAND_64K in capabilities:
             if progress is None:
             if progress is None:
@@ -579,13 +615,17 @@ class GitClient(object):
                                  wants, can_read, depth):
                                  wants, can_read, depth):
         """Handle the head of a 'git-upload-pack' request.
         """Handle the head of a 'git-upload-pack' request.
 
 
-        :param proto: Protocol object to read from
-        :param capabilities: List of negotiated capabilities
-        :param graph_walker: GraphWalker instance to call .ack() on
-        :param wants: List of commits to fetch
-        :param can_read: function that returns a boolean that indicates
-            whether there is extra graph data to read on proto
-        :param depth: Depth for request
+        Args:
+          proto: Protocol object to read from
+          capabilities: List of negotiated capabilities
+          graph_walker: GraphWalker instance to call .ack() on
+          wants: List of commits to fetch
+          can_read: function that returns a boolean that indicates
+        whether there is extra graph data to read on proto
+          depth: Depth for request
+
+        Returns:
+
         """
         """
         assert isinstance(wants, list) and isinstance(wants[0], bytes)
         assert isinstance(wants, list) and isinstance(wants[0], bytes)
         proto.write_pkt_line(COMMAND_WANT + b' ' + wants[0] + b' ' +
         proto.write_pkt_line(COMMAND_WANT + b' ' + wants[0] + b' ' +
@@ -633,12 +673,16 @@ class GitClient(object):
                                  pack_data, progress=None, rbufsize=_RBUFSIZE):
                                  pack_data, progress=None, rbufsize=_RBUFSIZE):
         """Handle the tail of a 'git-upload-pack' request.
         """Handle the tail of a 'git-upload-pack' request.
 
 
-        :param proto: Protocol object to read from
-        :param capabilities: List of negotiated capabilities
-        :param graph_walker: GraphWalker instance to call .ack() on
-        :param pack_data: Function to call with pack data
-        :param progress: Optional progress reporting function
-        :param rbufsize: Read buffer size
+        Args:
+          proto: Protocol object to read from
+          capabilities: List of negotiated capabilities
+          graph_walker: GraphWalker instance to call .ack() on
+          pack_data: Function to call with pack data
+          progress: Optional progress reporting function
+          rbufsize: Read buffer size
+
+        Returns:
+
         """
         """
         pkt = proto.read_pkt_line()
         pkt = proto.read_pkt_line()
         while pkt:
         while pkt:
@@ -670,8 +714,12 @@ class GitClient(object):
 def check_wants(wants, refs):
 def check_wants(wants, refs):
     """Check that a set of wants is valid.
     """Check that a set of wants is valid.
 
 
-    :param wants: Set of object SHAs to fetch
-    :param refs: Refs dictionary to check against
+    Args:
+      wants: Set of object SHAs to fetch
+      refs: Refs dictionary to check against
+
+    Returns:
+
     """
     """
     missing = set(wants) - {
     missing = set(wants) - {
             v for (k, v) in refs.items()
             v for (k, v) in refs.items()
@@ -681,7 +729,6 @@ def check_wants(wants, refs):
 
 
 
 
 def remote_error_from_stderr(stderr):
 def remote_error_from_stderr(stderr):
-    """Return an appropriate exception based on stderr output. """
     if stderr is None:
     if stderr is None:
         return HangupException()
         return HangupException()
     for l in stderr.readlines():
     for l in stderr.readlines():
@@ -710,8 +757,9 @@ class TraditionalGitClient(GitClient):
         for use and a can_read function which may be used to see if
         for use and a can_read function which may be used to see if
         reads would block.
         reads would block.
 
 
-        :param cmd: The git service name to which we should connect.
-        :param path: The path we should pass to the service. (as bytestirng)
+        Args:
+          cmd: The git service name to which we should connect.
+          path: The path we should pass to the service. (as bytestirng)
         """
         """
         raise NotImplementedError()
         raise NotImplementedError()
 
 
@@ -719,19 +767,24 @@ class TraditionalGitClient(GitClient):
                   progress=None):
                   progress=None):
         """Upload a pack to a remote repository.
         """Upload a pack to a remote repository.
 
 
-        :param path: Repository path (as bytestring)
-        :param update_refs: Function to determine changes to remote refs.
-            Receive dict with existing remote refs, returns dict with
-            changed refs (name -> sha, where sha=ZERO_SHA for deletions)
-        :param generate_pack_data: Function that can return a tuple with
-            number of objects and pack data to upload.
-        :param progress: Optional callback called with progress updates
-
-        :raises SendPackError: if server rejects the pack data
-        :raises UpdateRefsError: if the server supports report-status
-                                 and rejects ref updates
-        :return: new_refs dictionary containing the changes that were made
-            {refname: new_ref}, including deleted refs.
+        Args:
+          path: Repository path (as bytestring)
+          update_refs: Function to determine changes to remote refs.
+        Receive dict with existing remote refs, returns dict with
+        changed refs (name -> sha, where sha=ZERO_SHA for deletions)
+          generate_pack_data: Function that can return a tuple with
+        number of objects and pack data to upload.
+          progress: Optional callback called with progress updates
+
+        Returns:
+          new_refs dictionary containing the changes that were made
+          {refname: new_ref}, including deleted refs.
+
+        Raises:
+          SendPackError: if server rejects the pack data
+          UpdateRefsError: if the server supports report-status
+                         and rejects ref updates
+
         """
         """
         proto, unused_can_read, stderr = self._connect(b'receive-pack', path)
         proto, unused_can_read, stderr = self._connect(b'receive-pack', path)
         with proto:
         with proto:
@@ -798,15 +851,19 @@ class TraditionalGitClient(GitClient):
                    progress=None, depth=None):
                    progress=None, depth=None):
         """Retrieve a pack from a git smart server.
         """Retrieve a pack from a git smart server.
 
 
-        :param path: Remote path to fetch from
-        :param determine_wants: Function determine what refs
-            to fetch. Receives dictionary of name->sha, should return
-            list of shas to fetch.
-        :param graph_walker: Object with next() and ack().
-        :param pack_data: Callback called for each bit of data in the pack
-        :param progress: Callback for progress reports (strings)
-        :param depth: Shallow fetch depth
-        :return: FetchPackResult object
+        Args:
+          path: Remote path to fetch from
+          determine_wants: Function determine what refs
+        to fetch. Receives dictionary of name->sha, should return
+        list of shas to fetch.
+          graph_walker: Object with next() and ack().
+          pack_data: Callback called for each bit of data in the pack
+          progress: Callback for progress reports (strings)
+          depth: Shallow fetch depth
+
+        Returns:
+          FetchPackResult object
+
         """
         """
         proto, can_read, stderr = self._connect(b'upload-pack', path)
         proto, can_read, stderr = self._connect(b'upload-pack', path)
         with proto:
         with proto:
@@ -842,7 +899,8 @@ class TraditionalGitClient(GitClient):
                     refs, symrefs, agent, new_shallow, new_unshallow)
                     refs, symrefs, agent, new_shallow, new_unshallow)
 
 
     def get_refs(self, path):
     def get_refs(self, path):
-        """Retrieve the current refs from a git smart server."""
+        """Retrieve the current refs from a git smart server.
+        """
         # stock `git ls-remote` uses upload-pack
         # stock `git ls-remote` uses upload-pack
         proto, _, stderr = self._connect(b'upload-pack', path)
         proto, _, stderr = self._connect(b'upload-pack', path)
         with proto:
         with proto:
@@ -982,8 +1040,7 @@ class SubprocessWrapper(object):
 
 
 
 
 def find_git_command():
 def find_git_command():
-    """Find command to run for system Git (usually C Git).
-    """
+    """Find command to run for system Git (usually C Git)."""
     if sys.platform == 'win32':  # support .exe, .bat and .cmd
     if sys.platform == 'win32':  # support .exe, .bat and .cmd
         try:  # to avoid overhead
         try:  # to avoid overhead
             import win32api
             import win32api
@@ -1028,8 +1085,9 @@ class LocalGitClient(GitClient):
     def __init__(self, thin_packs=True, report_activity=None, config=None):
     def __init__(self, thin_packs=True, report_activity=None, config=None):
         """Create a new LocalGitClient instance.
         """Create a new LocalGitClient instance.
 
 
-        :param thin_packs: Whether or not thin packs should be retrieved
-        :param report_activity: Optional callback for reporting transport
+        Args:
+          thin_packs: Whether or not thin packs should be retrieved
+          report_activity: Optional callback for reporting transport
             activity.
             activity.
         """
         """
         self._report_activity = report_activity
         self._report_activity = report_activity
@@ -1053,19 +1111,24 @@ class LocalGitClient(GitClient):
                   progress=None):
                   progress=None):
         """Upload a pack to a remote repository.
         """Upload a pack to a remote repository.
 
 
-        :param path: Repository path (as bytestring)
-        :param update_refs: Function to determine changes to remote refs.
-            Receive dict with existing remote refs, returns dict with
-            changed refs (name -> sha, where sha=ZERO_SHA for deletions)
-        :param generate_pack_data: Function that can return a tuple
-            with number of items and pack data to upload.
-        :param progress: Optional progress function
-
-        :raises SendPackError: if server rejects the pack data
-        :raises UpdateRefsError: if the server supports report-status
-                                 and rejects ref updates
-        :return: new_refs dictionary containing the changes that were made
-            {refname: new_ref}, including deleted refs.
+        Args:
+          path: Repository path (as bytestring)
+          update_refs: Function to determine changes to remote refs.
+        Receive dict with existing remote refs, returns dict with
+        changed refs (name -> sha, where sha=ZERO_SHA for deletions)
+          generate_pack_data: Function that can return a tuple
+        with number of items and pack data to upload.
+          progress: Optional progress function
+
+        Returns:
+          new_refs dictionary containing the changes that were made
+          {refname: new_ref}, including deleted refs.
+
+        Raises:
+          SendPackError: if server rejects the pack data
+          UpdateRefsError: if the server supports report-status
+                         and rejects ref updates
+
         """
         """
         if not progress:
         if not progress:
             def progress(x):
             def progress(x):
@@ -1107,14 +1170,18 @@ class LocalGitClient(GitClient):
               depth=None):
               depth=None):
         """Fetch into a target repository.
         """Fetch into a target repository.
 
 
-        :param path: Path to fetch from (as bytestring)
-        :param target: Target repository to fetch into
-        :param determine_wants: Optional function determine what refs
-            to fetch. Receives dictionary of name->sha, should return
-            list of shas to fetch. Defaults to all shas.
-        :param progress: Optional progress function
-        :param depth: Shallow fetch depth
-        :return: FetchPackResult object
+        Args:
+          path: Path to fetch from (as bytestring)
+          target: Target repository to fetch into
+          determine_wants: Optional function determine what refs
+        to fetch. Receives dictionary of name->sha, should return
+        list of shas to fetch. Defaults to all shas.
+          progress: Optional progress function
+          depth: Shallow fetch depth
+
+        Returns:
+          FetchPackResult object
+
         """
         """
         with self._open_repo(path) as r:
         with self._open_repo(path) as r:
             refs = r.fetch(target, determine_wants=determine_wants,
             refs = r.fetch(target, determine_wants=determine_wants,
@@ -1126,15 +1193,19 @@ class LocalGitClient(GitClient):
                    progress=None, depth=None):
                    progress=None, depth=None):
         """Retrieve a pack from a git smart server.
         """Retrieve a pack from a git smart server.
 
 
-        :param path: Remote path to fetch from
-        :param determine_wants: Function determine what refs
-            to fetch. Receives dictionary of name->sha, should return
-            list of shas to fetch.
-        :param graph_walker: Object with next() and ack().
-        :param pack_data: Callback called for each bit of data in the pack
-        :param progress: Callback for progress reports (strings)
-        :param depth: Shallow fetch depth
-        :return: FetchPackResult object
+        Args:
+          path: Remote path to fetch from
+          determine_wants: Function determine what refs
+        to fetch. Receives dictionary of name->sha, should return
+        list of shas to fetch.
+          graph_walker: Object with next() and ack().
+          pack_data: Callback called for each bit of data in the pack
+          progress: Callback for progress reports (strings)
+          depth: Shallow fetch depth
+
+        Returns:
+          FetchPackResult object
+
         """
         """
         with self._open_repo(path) as r:
         with self._open_repo(path) as r:
             objects_iter = r.fetch_objects(
             objects_iter = r.fetch_objects(
@@ -1151,7 +1222,8 @@ class LocalGitClient(GitClient):
             return FetchPackResult(r.get_refs(), symrefs, agent)
             return FetchPackResult(r.get_refs(), symrefs, agent)
 
 
     def get_refs(self, path):
     def get_refs(self, path):
-        """Retrieve the current refs from a git smart server."""
+        """Retrieve the current refs from a git smart server.
+        """
 
 
         with self._open_repo(path) as target:
         with self._open_repo(path) as target:
             return target.get_refs()
             return target.get_refs()
@@ -1181,12 +1253,16 @@ class SSHVendor(object):
         Run a command remotely and return a file-like object for interaction
         Run a command remotely and return a file-like object for interaction
         with the remote command.
         with the remote command.
 
 
-        :param host: Host name
-        :param command: Command to run (as argv array)
-        :param username: Optional ame of user to log in as
-        :param port: Optional SSH port to use
-        :param password: Optional ssh password for login or private key
-        :param key_filename: Optional path to private keyfile
+        Args:
+          host: Host name
+          command: Command to run (as argv array)
+          username: Optional ame of user to log in as
+          port: Optional SSH port to use
+          password: Optional ssh password for login or private key
+          key_filename: Optional path to private keyfile
+
+        Returns:
+
         """
         """
         raise NotImplementedError(self.run_command)
         raise NotImplementedError(self.run_command)
 
 
@@ -1348,10 +1424,14 @@ def default_urllib3_manager(config, **override_kwargs):
 
 
     Honour detected proxy configurations.
     Honour detected proxy configurations.
 
 
-    :param config: `dulwich.config.ConfigDict` instance with Git configuration.
-    :param kwargs: Additional arguments for urllib3.ProxyManager
-    :return: `urllib3.ProxyManager` instance for proxy configurations,
-        `urllib3.PoolManager` otherwise.
+    Args:
+      config: dulwich.config.ConfigDict` instance with Git configuration.
+      kwargs: Additional arguments for urllib3.ProxyManager
+
+    Returns:
+      urllib3.ProxyManager` instance for proxy configurations,
+      `urllib3.PoolManager` otherwise.
+
     """
     """
     proxy_server = user_agent = None
     proxy_server = user_agent = None
     ca_certs = ssl_verify = None
     ca_certs = ssl_verify = None
@@ -1478,14 +1558,18 @@ class HttpGitClient(GitClient):
                       allow_compression=False):
                       allow_compression=False):
         """Perform HTTP request.
         """Perform HTTP request.
 
 
-        :param url: Request URL.
-        :param headers: Optional custom headers to override defaults.
-        :param data: Request data.
-        :param allow_compression: Allow GZipped communication.
-        :return: Tuple (`response`, `read`), where response is an `urllib3`
-            response object with additional `content_type` and
-            `redirect_location` properties, and `read` is a consumable read
-            method for the response data.
+        Args:
+          url: Request URL.
+          headers: Optional custom headers to override defaults.
+          data: Request data.
+          allow_compression: Allow GZipped communication.
+
+        Returns:
+          Tuple (`response`, `read`), where response is an `urllib3`
+          response object with additional `content_type` and
+          `redirect_location` properties, and `read` is a consumable read
+          method for the response data.
+
         """
         """
         req_headers = self.pool_manager.headers.copy()
         req_headers = self.pool_manager.headers.copy()
         if headers is not None:
         if headers is not None:
@@ -1576,19 +1660,24 @@ class HttpGitClient(GitClient):
                   progress=None):
                   progress=None):
         """Upload a pack to a remote repository.
         """Upload a pack to a remote repository.
 
 
-        :param path: Repository path (as bytestring)
-        :param update_refs: Function to determine changes to remote refs.
-            Receive dict with existing remote refs, returns dict with
-            changed refs (name -> sha, where sha=ZERO_SHA for deletions)
-        :param generate_pack_data: Function that can return a tuple
-            with number of elements and pack data to upload.
-        :param progress: Optional progress function
-
-        :raises SendPackError: if server rejects the pack data
-        :raises UpdateRefsError: if the server supports report-status
-                                 and rejects ref updates
-        :return: new_refs dictionary containing the changes that were made
-            {refname: new_ref}, including deleted refs.
+        Args:
+          path: Repository path (as bytestring)
+          update_refs: Function to determine changes to remote refs.
+        Receive dict with existing remote refs, returns dict with
+        changed refs (name -> sha, where sha=ZERO_SHA for deletions)
+          generate_pack_data: Function that can return a tuple
+        with number of elements and pack data to upload.
+          progress: Optional progress function
+
+        Returns:
+          new_refs dictionary containing the changes that were made
+          {refname: new_ref}, including deleted refs.
+
+        Raises:
+          SendPackError: if server rejects the pack data
+          UpdateRefsError: if the server supports report-status
+                         and rejects ref updates
+
         """
         """
         url = self._get_url(path)
         url = self._get_url(path)
         old_refs, server_capabilities, url = self._discover_references(
         old_refs, server_capabilities, url = self._discover_references(
@@ -1631,12 +1720,17 @@ class HttpGitClient(GitClient):
                    progress=None, depth=None):
                    progress=None, depth=None):
         """Retrieve a pack from a git smart server.
         """Retrieve a pack from a git smart server.
 
 
-        :param determine_wants: Callback that returns list of commits to fetch
-        :param graph_walker: Object with next() and ack().
-        :param pack_data: Callback called for each bit of data in the pack
-        :param progress: Callback for progress reports (strings)
-        :param depth: Depth for request
-        :return: FetchPackResult object
+        Args:
+          path: Path to fetch from
+          determine_wants: Callback that returns list of commits to fetch
+          graph_walker: Object with next() and ack().
+          pack_data: Callback called for each bit of data in the pack
+          progress: Callback for progress reports (strings)
+          depth: Depth for request
+
+        Returns:
+          FetchPackResult object
+
         """
         """
         url = self._get_url(path)
         url = self._get_url(path)
         refs, server_capabilities, url = self._discover_references(
         refs, server_capabilities, url = self._discover_references(
@@ -1672,7 +1766,8 @@ class HttpGitClient(GitClient):
             resp.close()
             resp.close()
 
 
     def get_refs(self, path):
     def get_refs(self, path):
-        """Retrieve the current refs from a git smart server."""
+        """Retrieve the current refs from a git smart server.
+        """
         url = self._get_url(path)
         url = self._get_url(path)
         refs, _, _ = self._discover_references(
         refs, _, _ = self._discover_references(
             b"git-upload-pack", url)
             b"git-upload-pack", url)
@@ -1682,12 +1777,16 @@ class HttpGitClient(GitClient):
 def get_transport_and_path_from_url(url, config=None, **kwargs):
 def get_transport_and_path_from_url(url, config=None, **kwargs):
     """Obtain a git client from a URL.
     """Obtain a git client from a URL.
 
 
-    :param url: URL to open (a unicode string)
-    :param config: Optional config object
-    :param thin_packs: Whether or not thin packs should be retrieved
-    :param report_activity: Optional callback for reporting transport
+    Args:
+      url: URL to open (a unicode string)
+      config: Optional config object
+      thin_packs: Whether or not thin packs should be retrieved
+      report_activity: Optional callback for reporting transport
         activity.
         activity.
-    :return: Tuple with client instance and relative path.
+
+    Returns:
+      Tuple with client instance and relative path.
+
     """
     """
     parsed = urlparse.urlparse(url)
     parsed = urlparse.urlparse(url)
     if parsed.scheme == 'git':
     if parsed.scheme == 'git':
@@ -1706,7 +1805,8 @@ def get_transport_and_path_from_url(url, config=None, **kwargs):
 
 
 
 
 def parse_rsync_url(location):
 def parse_rsync_url(location):
-    """Parse a rsync-style URL."""
+    """Parse a rsync-style URL.
+    """
     if ':' in location and '@' not in location:
     if ':' in location and '@' not in location:
         # SSH with no user@, zero or one leading slash.
         # SSH with no user@, zero or one leading slash.
         (host, path) = location.split(':', 1)
         (host, path) = location.split(':', 1)
@@ -1727,12 +1827,16 @@ def parse_rsync_url(location):
 def get_transport_and_path(location, **kwargs):
 def get_transport_and_path(location, **kwargs):
     """Obtain a git client from a URL.
     """Obtain a git client from a URL.
 
 
-    :param location: URL or path (a string)
-    :param config: Optional config object
-    :param thin_packs: Whether or not thin packs should be retrieved
-    :param report_activity: Optional callback for reporting transport
+    Args:
+      location: URL or path (a string)
+      config: Optional config object
+      thin_packs: Whether or not thin packs should be retrieved
+      report_activity: Optional callback for reporting transport
         activity.
         activity.
-    :return: Tuple with client instance and relative path.
+
+    Returns:
+      Tuple with client instance and relative path.
+
     """
     """
     # First, try to parse it as a URL
     # First, try to parse it as a URL
     try:
     try:

+ 30 - 17
dulwich/config.py

@@ -119,21 +119,27 @@ class Config(object):
     def get(self, section, name):
     def get(self, section, name):
         """Retrieve the contents of a configuration setting.
         """Retrieve the contents of a configuration setting.
 
 
-        :param section: Tuple with section name and optional subsection namee
-        :param subsection: Subsection name
-        :return: Contents of the setting
-        :raise KeyError: if the value is not set
+        Args:
+          section: Tuple with section name and optional subsection namee
+          subsection: Subsection name
+        Returns:
+          Contents of the setting
+        Raises:
+          KeyError: if the value is not set
         """
         """
         raise NotImplementedError(self.get)
         raise NotImplementedError(self.get)
 
 
     def get_boolean(self, section, name, default=None):
     def get_boolean(self, section, name, default=None):
         """Retrieve a configuration setting as boolean.
         """Retrieve a configuration setting as boolean.
 
 
-        :param section: Tuple with section name and optional subsection name
-        :param name: Name of the setting, including section and possible
+        Args:
+          section: Tuple with section name and optional subsection name
+          name: Name of the setting, including section and possible
             subsection.
             subsection.
-        :return: Contents of the setting
-        :raise KeyError: if the value is not set
+        Returns:
+          Contents of the setting
+        Raises:
+          KeyError: if the value is not set
         """
         """
         try:
         try:
             value = self.get(section, name)
             value = self.get(section, name)
@@ -148,18 +154,21 @@ class Config(object):
     def set(self, section, name, value):
     def set(self, section, name, value):
         """Set a configuration value.
         """Set a configuration value.
 
 
-        :param section: Tuple with section name and optional subsection namee
-        :param name: Name of the configuration value, including section
+        Args:
+          section: Tuple with section name and optional subsection namee
+          name: Name of the configuration value, including section
             and optional subsection
             and optional subsection
-        :param: Value of the setting
+           value: value of the setting
         """
         """
         raise NotImplementedError(self.set)
         raise NotImplementedError(self.set)
 
 
     def iteritems(self, section):
     def iteritems(self, section):
         """Iterate over the configuration pairs for a specific section.
         """Iterate over the configuration pairs for a specific section.
 
 
-        :param section: Tuple with section name and optional subsection namee
-        :return: Iterator over (name, value) pairs
+        Args:
+          section: Tuple with section name and optional subsection namee
+        Returns:
+          Iterator over (name, value) pairs
         """
         """
         raise NotImplementedError(self.iteritems)
         raise NotImplementedError(self.iteritems)
 
 
@@ -173,8 +182,10 @@ class Config(object):
     def has_section(self, name):
     def has_section(self, name):
         """Check if a specified section exists.
         """Check if a specified section exists.
 
 
-        :param name: Name of section to check for
-        :return: boolean indicating whether the section exists
+        Args:
+          name: Name of section to check for
+        Returns:
+          boolean indicating whether the section exists
         """
         """
         return (name in self.itersections())
         return (name in self.itersections())
 
 
@@ -538,8 +549,10 @@ class StackedConfig(Config):
 def parse_submodules(config):
 def parse_submodules(config):
     """Parse a gitmodules GitConfig file, returning submodules.
     """Parse a gitmodules GitConfig file, returning submodules.
 
 
-   :param config: A `ConfigFile`
-   :return: list of tuples (submodule path, url, name),
+   Args:
+     config: A `ConfigFile`
+   Returns:
+     list of tuples (submodule path, url, name),
        where name is quoted part of the section's name.
        where name is quoted part of the section's name.
     """
     """
     for section in config.keys():
     for section in config.keys():