def create_edit_issue(issue=None, text=None): main_text = """# Please explain the issue. # The first line will be used as the title. # Lines starting with `#` will be ignored.""" if issue: issue['main'] = main_text template = """%(title)s %(body)s %(main)s # # number: %(number)s # user: %(user)s # votes: %(votes)s # state: %(state)s # created: %(created_at)s""" % issue else: template = "\n%s" % main_text if text: # \n on the command-line becomes \\n; undoing this: text = text.replace("\\n", "\n") else: text = edit_text(template) if not text: raise Exception("can not submit an empty issue") lines = text.splitlines() title = lines[0] body = "\n".join(lines[1:]).strip() return {'title': title, 'body': body}
def create_comment(issue): inp = """ # Please enter a comment. # Lines starting with `#` will be ignored. # # number: %(number)s # user: %(user)s # votes: %(votes)s # state: %(state)s # created: %(created_at)s""" % issue out = edit_text(inp) if not out: raise Exception("can not submit an empty comment") lines = out.splitlines() comment = "\n".join(lines).strip() return comment
def create_comment(issue=None, text=None): inp = """ # Please enter a comment. # Lines starting with `#` will be ignored. # # number: %(number)s # user: %(user)s # votes: %(votes)s # state: %(state)s # created: %(created_at)s""" % issue if text: # \n on the command-line becomes \\n; undoing this: out = text.replace("\\n", "\n") else: out = edit_text(inp) if not out: raise Exception("can not submit an empty comment") lines = out.splitlines() comment = "\n".join(lines).strip() return comment