From 629fbd14ad97fe931ce162374ade0137e440e354 Mon Sep 17 00:00:00 2001 From: Stefano Rivera Date: Sun, 13 Nov 2011 20:53:39 +0200 Subject: [PATCH] optional_edit was a silly idea --- requestsync | 5 +---- ubuntutools/question.py | 17 ++++++++--------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/requestsync b/requestsync index 22aefc3..ffcc2dd 100755 --- a/requestsync +++ b/requestsync @@ -305,10 +305,7 @@ def main(): report += changelog editor = EditBugReport(title, report) - if need_interaction: - editor.edit() - else: - editor.optional_edit() + editor.edit(optional=not need_interaction) title, report = editor.get_report() if 'XXX FIXME' in report: diff --git a/ubuntutools/question.py b/ubuntutools/question.py index 124f66e..60c8f13 100644 --- a/ubuntutools/question.py +++ b/ubuntutools/question.py @@ -119,15 +119,14 @@ class EditFile(object): placeholders = (re.compile(r'^<<<.*>>>$', re.UNICODE),) self.placeholders = placeholders - def optional_edit(self): - '''Prompt the user to decide if the file needs editing''' - print "Currently the %s looks like:" % self.description - with open(self.filename, 'r') as f: - print f.read() - if YesNoQuestion().ask("Edit", "no") == "yes": - self.edit() + def edit(self, optional=False): + if optional: + print "Currently the %s looks like:" % self.description + with open(self.filename, 'r') as f: + print f.read() + if YesNoQuestion().ask("Edit", "no") == "no": + return - def edit(self): done = False while not done: old_mtime = os.stat(self.filename).st_mtime @@ -146,7 +145,7 @@ class EditFile(object): print ("Placeholders still present in the %s. " "Please replace them with useful information." % self.description) - confirmation_prompt('edit again') + confirmation_prompt(action='edit again') elif not modified: print "The %s was not modified" % self.description if YesNoQuestion().ask("Edit again", "yes") == "no":