optional_edit was a silly idea

This commit is contained in:
Stefano Rivera 2011-11-13 20:53:39 +02:00
parent 054423d016
commit 629fbd14ad
2 changed files with 9 additions and 13 deletions

View File

@ -305,10 +305,7 @@ def main():
report += changelog report += changelog
editor = EditBugReport(title, report) editor = EditBugReport(title, report)
if need_interaction: editor.edit(optional=not need_interaction)
editor.edit()
else:
editor.optional_edit()
title, report = editor.get_report() title, report = editor.get_report()
if 'XXX FIXME' in report: if 'XXX FIXME' in report:

View File

@ -119,15 +119,14 @@ class EditFile(object):
placeholders = (re.compile(r'^<<<.*>>>$', re.UNICODE),) placeholders = (re.compile(r'^<<<.*>>>$', re.UNICODE),)
self.placeholders = placeholders self.placeholders = placeholders
def optional_edit(self): def edit(self, optional=False):
'''Prompt the user to decide if the file needs editing''' if optional:
print "Currently the %s looks like:" % self.description print "Currently the %s looks like:" % self.description
with open(self.filename, 'r') as f: with open(self.filename, 'r') as f:
print f.read() print f.read()
if YesNoQuestion().ask("Edit", "no") == "yes": if YesNoQuestion().ask("Edit", "no") == "no":
self.edit() return
def edit(self):
done = False done = False
while not done: while not done:
old_mtime = os.stat(self.filename).st_mtime old_mtime = os.stat(self.filename).st_mtime
@ -146,7 +145,7 @@ class EditFile(object):
print ("Placeholders still present in the %s. " print ("Placeholders still present in the %s. "
"Please replace them with useful information." "Please replace them with useful information."
% self.description) % self.description)
confirmation_prompt('edit again') confirmation_prompt(action='edit again')
elif not modified: elif not modified:
print "The %s was not modified" % self.description print "The %s was not modified" % self.description
if YesNoQuestion().ask("Edit again", "yes") == "no": if YesNoQuestion().ask("Edit again", "yes") == "no":