Created
October 1, 2012 19:23
-
-
Save sigmavirus24/3813862 to your computer and use it in GitHub Desktop.
List of places to replace list functions with iter functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
github3/api.py:45:def list_gists(username=None): | |
github3/api.py:55:def list_followers(username): | |
github3/api.py:64:def list_following(username): | |
github3/api.py:72:def list_repo_issues(owner, repository, filter='', state='', l | |
abels='', | |
github3/api.py:82:def list_orgs(username): | |
github3/api.py:90:def list_repos(login, type='', sort='', direction=''): | |
github3/api.py:118:def list_events(): | |
github3/github.py:318: def list_authorizations(self): | |
github3/github.py:327: def list_emails(self): | |
github3/github.py:336: def list_events(self): | |
github3/github.py:345: def list_followers(self, login=None): | |
github3/github.py:358: def list_following(self, login=None): | |
github3/github.py:371: def list_gists(self, username=None): | |
github3/github.py:387: def list_user_issues(self, filter='', state='', labels | |
='', sort='', | |
github3/github.py:411: def list_repo_issues(self, owner, repository, mileston | |
e=None, | |
github3/github.py:442: def list_keys(self): | |
github3/github.py:451: def list_orgs(self, login=None): | |
github3/github.py:468: def list_repos(self, login=None, type='', sort='', dir | |
ection=''): | |
github3/github.py:507: def list_starred(self, login=None): | |
github3/github.py:519: def list_subscribed(self, login=None): | |
github3/github.py:532: def list_watching(self, login=None): | |
github3/repos.py:826: def list_assignees(self): | |
github3/repos.py:835: def list_branches(self): | |
github3/repos.py:845: def list_comments(self): | |
github3/repos.py:855: def list_comments_on_commit(self, sha): | |
github3/repos.py:870: def list_commits(self, sha='', path='', author=''): | |
github3/repos.py:887: def list_contributors(self, anon=False): | |
github3/repos.py:902: def list_downloads(self): | |
github3/repos.py:912: def list_events(self): | |
github3/repos.py:922: def list_forks(self, sort=''): | |
github3/repos.py:939: def list_hooks(self): | |
github3/repos.py:949: def list_issues(self, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An example of how to transform a list function an iter function | |
""" | |
def list_network_events(self): | |
"""Doc-string starting with the verb "List" | |
:returns: list of :class:`Event <github3.events.Event>` | |
""" | |
url = self._build_url("...") | |
# request | |
return ["Events"] | |
def iter_network_events(self, number=-1): | |
"""Same doc-string as above replacing "List" with "Iterates over" | |
:param int number: (optional), number of network events to return. Default: -1 returns all available network events. | |
:returns: generator of :class:`Event <github3.events.Event>` | |
""" | |
url = self._build_url("...") | |
return self._iter(int(number), url, Event) | |
# If the class you're using inherits directly from GitHubObject instead of GitHubCore, you set the last parameter to False. | |
# Also in the equivalent tests/test_(mod_name).py file, make a test next to the list function for the iter_function. An example test is: | |
def test_iter_network_events(self): | |
expect(next(self.repo.iter_network_events(1))).isinstance(Event) | |
# If the function takes other parameters, a test for those parameters individually or in bulk can be added as well. | |
# e.g., list_milestones() -> iter_milestones() can have | |
def test_iter_milestones(self): | |
expect(next(self.repo.iter_milestones(number=1))).isinstance(Event) | |
expect(next(self.repo.iter_milestones(state='open', number=1))).isinstance(Event) | |
# once more for the remaining two OR just | |
expect(next(self.repo.iter_milestones('open', 'sort_param', 'asc', 1))).isinstance(Event) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment