Permalink
Browse files

Merge branch 'feat/pep_257'

* feat/pep_257:
  Use class docstring with autodoc.
  Added some more missing docstrings.
  [QA] Use imperative form as per PEP 257.
  [QA] Use PEP 257 punctuation guidelines.
  [QA] Follow PEP 257 whitespace rules.
  • Loading branch information...
2 parents 3a82036 + 031018e commit d8f4d6c500b7e23def619753c54bec722b56bb18 @JNRowe JNRowe committed May 16, 2012
View
@@ -229,7 +229,7 @@
[u'Ask Solem'], 1)
]
-autoclass_content = "init"
+autoclass_content = "class"
autodoc_default_flags = ['members', ]
intersphinx_mapping = {
View
@@ -1,4 +1,4 @@
-"Github API v2 library for Python"
+"GitHub API v2 library for Python."
from github2 import _version
@@ -24,17 +24,19 @@
def print_(text):
- """Python 2 & 3 compatible print function
+ """Python 2 & 3 compatible print function.
- We support <2.6, so can't use __future__.print_function"""
+ We support <2.6, so can't use __future__.print_function
+
+ """
if PY3K:
print(text)
else:
sys.stdout.write(text + '\n')
def parse_commandline():
- """Parse the comandline and return parsed options."""
+ """Parse the command line and return parsed options."""
parser = OptionParser()
parser.description = __doc__
@@ -73,7 +75,7 @@ def parse_commandline():
def main():
- """This implements the actual program functionality"""
+ """Implement the actual program functionality."""
options, args = parse_commandline()
@@ -17,17 +17,19 @@
def print_(text):
- """Python 2 & 3 compatible print function
+ """Python 2 & 3 compatible print function.
- We support <2.6, so can't use __future__.print_function"""
+ We support <2.6, so can't use __future__.print_function
+
+ """
if PY3K:
print(text)
else:
sys.stdout.write(text + '\n')
def parse_commandline():
- """Parse the comandline and return parsed options."""
+ """Parse the command line and return parsed options."""
parser = OptionParser()
parser.description = __doc__
@@ -46,7 +48,7 @@ def parse_commandline():
def main():
- """This implements the actual program functionality"""
+ """Implement the actual program functionality."""
return_value = 0
options, term = parse_commandline()
View
@@ -10,12 +10,12 @@
class Github(object):
+ """Interface to GitHub's API v2."""
+
def __init__(self, username=None, api_token=None, requests_per_second=None,
access_token=None, cache=None, proxy_host=None,
proxy_port=8080, github_url=None):
- """
- An interface to GitHub's API:
- http://develop.github.com/
+ """Setup GitHub API object.
.. versionadded:: 0.2.0
The ``requests_per_second`` parameter
@@ -42,6 +42,7 @@ def __init__(self, username=None, api_token=None, requests_per_second=None,
default to 8080 if a proxy_host is set and no port is set).
:param str github_url: the hostname to connect to, for GitHub
Enterprise support
+
"""
self.request = GithubRequest(username=username, api_token=api_token,
@@ -59,59 +60,65 @@ def __init__(self, username=None, api_token=None, requests_per_second=None,
self.pull_requests = PullRequests(self.request)
def project_for_user_repo(self, user, repo):
- """Return GitHub identifier for a user's repository
+ """Return GitHub identifier for a user's repository.
:param str user: repository owner
:param str repo: repository name
+
"""
return "/".join([user, repo])
def get_all_blobs(self, project, tree_sha):
- """Get a list of all blobs for a specific tree
+ """Get a list of all blobs for a specific tree.
.. versionadded:: 0.3.0
:param str project: GitHub project
:param str tree_sha: object ID of tree
+
"""
blobs = self.request.get("blob/all", project, tree_sha)
return blobs.get("blobs")
def get_blob_info(self, project, tree_sha, path):
- """Get the blob for a file within a specific tree
+ """Get the blob for a file within a specific tree.
:param str project: GitHub project
:param str tree_sha: object ID of tree
:param str path: path within tree to fetch blob for
+
"""
blob = self.request.get("blob/show", project, tree_sha, path)
return blob.get("blob")
def get_tree(self, project, tree_sha):
- """Get tree information for a specifc tree
+ """Get tree information for a specifc tree.
:param str project: GitHub project
:param str tree_sha: object ID of tree
+
"""
tree = self.request.get("tree/show", project, tree_sha)
return tree.get("tree", [])
def get_network_meta(self, project):
- """Get GitHub metadata associated with a project
+ """Get GitHub metadata associated with a project.
:param str project: GitHub project
+
"""
return self.request.raw_request("/".join([self.request.github_url,
project,
"network_meta"]), {})
def get_network_data(self, project, nethash, start=None, end=None):
- """Get chunk of GitHub network data
+ """Get chunk of GitHub network data.
:param str project: GitHub project
:param str nethash: identifier provided by :meth:`get_network_meta`
:param int start: optional start point for data
:param int stop: optional end point for data
+
"""
data = {"nethash": nethash}
if start:
View
@@ -3,6 +3,9 @@
class Commit(BaseData):
+
+ """Commit container."""
+
message = Attribute("Commit message.")
parents = Attribute("List of parents for this commit.")
url = Attribute("Canonical URL for this commit.")
@@ -25,10 +28,13 @@ def __repr__(self):
class Commits(GithubCommand):
+
+ """GitHub API commits functionality."""
+
domain = "commits"
def list(self, project, branch="master", file=None, page=1):
- """List commits on a project
+ """List commits on a project.
.. warning::
Not all projects use ``master`` as their default branch, you can
@@ -39,15 +45,17 @@ def list(self, project, branch="master", file=None, page=1):
:param str branch: branch name, or ``master`` if not given
:param str file: optional file filter
:param int page: optional page number
+
"""
return self.get_values("list", project, branch, file, filter="commits",
datatype=Commit, page=page)
def show(self, project, sha):
- """Get a specific commit
+ """Get a specific commit.
:param str project: project name
:param str sha: commit id
+
"""
return self.get_value("show", project, sha,
filter="commit", datatype=Commit)
Oops, something went wrong.

0 comments on commit d8f4d6c

Please sign in to comment.