Ejemplo n.º 1
0
    def show(self, number=None, verbose=False, webbrowser=False, **kwargs):
        validate_number(number, example="%s show 1" % get_prog())
        if webbrowser:
            issue_url_template = "https://github.com/%s/%s/issues/%s"
            issue_url = issue_url_template % (self.user, self.repo, number)
            try:
                browser.open(issue_url)
            except:
                print "error: opening page in web browser failed"
            else:
                sys.exit(0)

        issue = self.__get_issue(number)
        if not verbose:
            pprint_issue(issue)
        else:
            printer = Pager()
            lines = format_issue(issue, verbose=True)
            lines.insert(0, " ")
            printer.write("\n".join(lines))
            if issue.get("comments", 0) > 0:
                comments = self.__submit('comments', number)
                comments = get_key(comments, 'comments')
                lines = [] # reset
                total = len(comments)
                for i in range(total):
                    comment = comments[i]
                    lines.extend(format_comment(comment, i+1, total))
                    lines.append(" ")
                printer.write("\n".join(lines))
            printer.close()
Ejemplo n.º 2
0
 def search(self, search_term=None, state='open', verbose=False, **kwargs):
     if not search_term:
         example = "%s search experimental" % get_prog()
         msg = "error: search term required\nexample: %s" % example
         print msg
         sys.exit(1)
     search_term_quoted = urllib.quote_plus(search_term)
     search_term_quoted = search_term_quoted.replace(".", "%2E")
     result = self.__submit('search', search_term, state)
     issues = get_key(result, 'issues')
     header = "# searching for '%s' returned %s issues" % (search_term,
         len(issues))
     printer = Pager()
     printer.write(header)
     for issue in issues:
         lines = format_issue(issue, verbose)
         printer.write("\n".join(lines))
     printer.close()
Ejemplo n.º 3
0
 def search(self, search_term=None, state='open', verbose=False, **kwargs):
     if not search_term:
         example = "%s search experimental" % get_prog()
         msg = "error: search term required\nexample: %s" % example
         print msg
         sys.exit(1)
     search_term_quoted = urllib.quote_plus(search_term)
     search_term_quoted = search_term_quoted.replace(".", "%2E")
     result = self.__submit('search', search_term, state)
     issues = get_key(result, 'issues')
     header = "# searching for '%s' returned %s issues" % (search_term, len(issues))
     printer = Pager()
     printer.write(header)
     for issue in issues:
         lines = format_issue(issue, verbose)
         printer.write("\n".join(lines))
     printer.close()
Ejemplo n.º 4
0
    def list(self, state='open', verbose=False, webbrowser=False, 
            created_by=False, **kwargs):
        if webbrowser:
            issues_url_template = "https://github.com/%s/%s/issues/%s"
            if state == "closed":
                issues_url = issues_url_template % (self.user, self.repo,
                    state)
            else:
                issues_url = issues_url_template % (self.user, self.repo, "")
            try:
                browser.open(issues_url)
            except:
                print "error: opening page in web browser failed"
            else:
                sys.exit(0)

        if state == 'all':
            states = ['open', 'closed']
        else:
            states = [state]
        printer = Pager()
        for st in states:
            header = "# %s issues on %s/%s" % (st, self.user, self.repo)
            printer.write(header)
            result = self.__submit('list', st)
            issues = get_key(result, 'issues')
            if issues:
                for issue in issues:
                    if created_by == False or created_by == issue.get('user'):
                        lines = format_issue(issue, verbose)
                        printer.write("\n".join(lines))
            else:
                printer.write("no %s issues available" % st)
            if not st == states[-1]:
                printer.write() # new line between states
        printer.close()