def __init__(self, project, username=None, password=None): self.project = project self.client = ProjectHostingClient() if username and password: source = "-".join([COMPANY_NAME, APPLICATION_NAME, __version__]) self.client.client_login(username, password, source=source, service="code")
class GCodeFetcher(object): def __init__(self, project, username=None, password=None): self.project = project self.client = ProjectHostingClient() if username and password: source = "-".join([COMPANY_NAME, APPLICATION_NAME, __version__]) self.client.client_login(username, password, source=source, service="code") def get_all(self, get_from): start = 1 while True: feed = get_from(start) if not feed.entry: break for item in feed.entry: yield item start += 1 def issues(self, **kwargs): def get_issues_from(start): return self.client.get_issues(self.project, query=Query(pretty_print=True, start_index=start, **kwargs)) return self.get_all(get_issues_from) def short_id(self, issue_or_comment): # All we can directly get from an issue is a string like: # http://code.google.com/feeds/issues/p/support/issues/full/3238 # But if we want to get that issue's comments, the API won't accept # that, it needs the bare "3238". # # REST FAIL return issue_or_comment.id.text.split("/")[-1] def comments(self, issue, **kwargs): issue_id = self.short_id(issue) def get_comments_from(start): return self.client.get_comments(self.project, issue_id, query=Query(pretty_print=True, start_index=start, **kwargs)) return self.get_all(get_comments_from)