jenkins-bot merged this change.
[IMPR] use context manager to open a file
also remove hidden comment because it is unclear what to do with it
Change-Id: I88814540b446aceb138fdf0b335125e022c3013c
---
M scripts/editarticle.py
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/scripts/editarticle.py b/scripts/editarticle.py
index 938bde2..f89e58a 100755
--- a/scripts/editarticle.py
+++ b/scripts/editarticle.py
@@ -45,10 +45,6 @@
"""Edit a wiki page."""
- # join lines if line starts with this ones
- # TODO: No apparent usage
- # joinchars = string.letters + '[]' + string.digits
-
def __init__(self, *args):
"""Constructor."""
self.set_options(*args)
@@ -85,9 +81,8 @@
def handle_edit_conflict(self, new):
"""When an edit conflict occures save the new text to a file."""
fn = os.path.join(tempfile.gettempdir(), self.page.title())
- fp = open(fn, 'w')
- fp.write(new)
- fp.close()
+ with open(fn, 'w') as fp:
+ fp.write(new)
pywikibot.output(
"An edit conflict has arisen. Your edit has been saved to %s. "
"Please try again." % fn)
To view, visit change 425465. To unsubscribe, visit settings.