jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Fix the summary line in generate_user_files for user-fixes.py ......................................................................
[IMPROV] Fix the summary line in generate_user_files for user-fixes.py
Also update some doc strings and code parts from core.
Change-Id: Iac59759cbd08ff373879db0cddc3a333c5e4d9d2 --- M generate_user_files.py 1 file changed, 8 insertions(+), 7 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py index d51f0fa..741f9fd 100644 --- a/generate_user_files.py +++ b/generate_user_files.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- -""" Script to create user files (user-config.py, user-fixes.py) """ +"""Script to create user files (user-config.py, user-fixes.py).""" # -# (C) Pywikibot team, 2008-2013 +# (C) Pywikibot team, 2008-2015 # -# Distributed under the terms of the MIT license +# Distributed under the terms of the MIT license. # __version__ = '$Id$' # @@ -54,6 +54,7 @@
def file_exists(filename): + """Return whether the file exists and print a message if it exists.""" if os.path.exists(filename): print("'%s' already exists." % filename) return True @@ -149,10 +150,11 @@
def create_user_fixes(base_dir): + """Create a basic user-fixes.py in base_dir.""" _fnf = os.path.join(base_dir, "user-fixes.py") if not file_exists(_fnf): - f = codecs.open(_fnf, "w", "utf-8") - f.write(r"""# -*- coding: utf-8 -*- + with codecs.open(_fnf, "w", "utf-8") as f: + f.write(r"""# -*- coding: utf-8 -*-
# # This is only an example. Don't use it. @@ -161,7 +163,7 @@ fixes['example'] = { 'regex': True, 'msg': { - '_default':u'no summary specified', + '_default': u'no summary specified', }, 'replacements': [ (ur'\bword\b', u'two words'), @@ -169,7 +171,6 @@ }
""") - f.close() print("'%s' written." % _fnf)
pywikibot-commits@lists.wikimedia.org