jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/225825 )
Change subject: compat2core: use with statement instead of closing files manually
......................................................................
compat2core: use with statement instead of closing files manually
Also close a file earlier in ConvertBot.warning()
Signed-off-by: xqt <info(a)gno.de>
Change-Id: I56fd31f6080535edd00e60af93d816d6e7285b48
---
M scripts/maintenance/compat2core.py
1 file changed, 12 insertions(+), 13 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
Xqt: Looks good to me, but someone else must approve
diff --git a/scripts/maintenance/compat2core.py b/scripts/maintenance/compat2core.py
index 0ba7210..46c09a7 100755
--- a/scripts/maintenance/compat2core.py
+++ b/scripts/maintenance/compat2core.py
@@ -26,7 +26,7 @@
"""
#
# (C) xqt, 2014-2015
-# (C) Pywikibot team, 2014-2015
+# (C) Pywikibot team, 2014-2017
#
# Distributed under the terms of the MIT license.
#
@@ -168,24 +168,23 @@
def convert(self):
"""Convert script."""
- f = codecs.open(self.source, "r", "utf-8")
- text = f.read()
- f.close()
+ with codecs.open(self.source, 'r', 'utf-8') as f:
+ text = f.read()
for r in replacements:
text = re.sub(r[0], r[1], text)
- g = codecs.open(self.dest, "w", "utf-8")
- g.write(text)
- g.close()
+ with codecs.open(self.dest, 'w', 'utf-8') as g:
+ g.write(text)
def warning(self):
"""Show warnings and hints."""
filename = self.source if self.warnonly else self.dest
- g = codecs.open(filename, "r", "utf-8")
- for i, line in enumerate(g, start=1):
- for w in warnings:
- if w[0] in line:
- pywikibot.warning(u'line %d: %s>>> %s\n' % (i, line, w[1]))
- g.close()
+ with codecs.open(filename, 'r', 'utf-8') as g:
+ lines = enumerate(g.readlines(), start=1)
+ for i, line in lines:
+ for w in warnings:
+ if w[0] in line:
+ pywikibot.warning(
+ 'line {0}: {1}>>> {2}\n'.format(i, line, w[1]))
def main():
--
To view, visit https://gerrit.wikimedia.org/r/225825
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I56fd31f6080535edd00e60af93d816d6e7285b48
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/342503 )
Change subject: Add another sandbox page to clean
......................................................................
Add another sandbox page to clean
Change-Id: I339ff9b7528c19d45c8f10d4486bcb04be33d625
---
M scripts/clean_sandbox.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py
index ea00fd2..2019321 100755
--- a/scripts/clean_sandbox.py
+++ b/scripts/clean_sandbox.py
@@ -107,7 +107,7 @@
'zh': '{{subst:User:Sz-iwbot/sandbox}}\n',
}
-sandbox_titles = ('Q3938', )
+sandbox_titles = ('Q3938', 'Q28939665')
# This is required for the text that is shown when you run this script
# with the parameter -help.
--
To view, visit https://gerrit.wikimedia.org/r/342503
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I339ff9b7528c19d45c8f10d4486bcb04be33d625
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>