jenkins-bot has submitted this change and it was merged.
Change subject: remove obsolete pywikibot.stopme() at the end of some other scripts.
......................................................................
remove obsolete pywikibot.stopme() at the end of some other scripts.
In core branch pywikibot.stopme() is called by atexit library.
The function is executed upon normal program termination. This
patch prohibits executing it twice.
Change-Id: Id6881a166b0e7032a78c09654dd1e6d5a5649590
---
M scripts/fixing_redirects.py
M scripts/image.py
2 files changed, 7 insertions(+), 10 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/fixing_redirects.py b/scripts/fixing_redirects.py
index c89d6db..ff105bc 100644
--- a/scripts/fixing_redirects.py
+++ b/scripts/fixing_redirects.py
@@ -16,7 +16,7 @@
#
# This script based on disambredir.py and solve_disambiguation.py
#
-# (C) Pywikipedia team, 2004-2012
+# (C) Pywikipedia team, 2004-2014
#
# Distributed under the terms of the MIT license.
#
@@ -224,7 +224,4 @@
pywikibot.showHelp('fixing_redirects')
if __name__ == "__main__":
- try:
- main()
- finally:
- pywikibot.stopme()
+ main()
diff --git a/scripts/image.py b/scripts/image.py
index d041736..fe50f48 100644
--- a/scripts/image.py
+++ b/scripts/image.py
@@ -34,9 +34,12 @@
python image.py Flag.jpg Flag.svg
"""
-__version__ = '$Id$'
+#
+# (C) Pywikibot team, 2013-2014
#
# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
#
import pywikibot
import replace
@@ -197,7 +200,4 @@
bot.run()
if __name__ == "__main__":
- try:
- main()
- finally:
- pywikibot.stopme()
+ main()
--
To view, visit https://gerrit.wikimedia.org/r/120035
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id6881a166b0e7032a78c09654dd1e6d5a5649590
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: remove old debugging stuff
......................................................................
remove old debugging stuff
Change-Id: I75ed7f8e35c6a510c2292445e6a3811789a901d2
---
M pywikibot/pagegenerators.py
1 file changed, 1 insertion(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index df3068e..b7bf132 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -13,7 +13,7 @@
¶ms;
"""
#
-# (C) Pywikibot team, 2008-2013
+# (C) Pywikibot team, 2008-2014
#
# Distributed under the terms of the MIT license.
#
@@ -1155,14 +1155,12 @@
continue
for result in data.results:
- #print 'DBG: ', result.URL
yield result.URL
# give an estimate of pages to work on, but only once.
if not estimatedTotalResultsCount:
pywikibot.output(u'Estimated total result count: %i pages.'
% data.meta.estimatedTotalResultsCount)
estimatedTotalResultsCount = data.meta.estimatedTotalResultsCount
- #print 'estimatedTotalResultsCount: ', estimatedTotalResultsCount
offset += 10
#############
@@ -1258,7 +1256,6 @@
except TypeError:
# Limit reached or no more results
break
- #print pageName
if pageName:
namespace = site.namespace(namespaceNumber)
pageName = unicode(pageName, site.encoding())
--
To view, visit https://gerrit.wikimedia.org/r/120038
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I75ed7f8e35c6a510c2292445e6a3811789a901d2
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [SYNC] Synchronize with core
......................................................................
[SYNC] Synchronize with core
* [BUGFIX] change site.lang to site.code [1]
* allow empty translations [2]
[1]
The i18n files use WMF language codes instead of ISO 639 language
codes. This means we also have to use these in our translations.
e.g. site code of the Alemannic wikipedia is 'als' whereas the
language code is 'gsw'. The i18n files use 'als', while we now
try to lookup 'gsw', which does not exist.
[2]
Check for 'trans is None' (= no translation found) instead of
for 'not trans' (= no translation found, or empty translation)
Can be relevant for empty configuration variables.
Change-Id: I519eae0c7c87d790c99c0c21658f87aa98409191
---
M pywikibot/i18n.py
1 file changed, 20 insertions(+), 18 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 8ae944c..e62d04d 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -1,13 +1,15 @@
# -*- coding: utf-8 -*-
-""" Various i18n functions, both for the internal translation system
- and for TranslateWiki-based translations
+"""
+Various i18n functions, both for the internal translation system
+and for TranslateWiki-based translations
"""
#
-# (C) Pywikipedia bot team, 2004-2013
+# (C) Pywikibot team, 2004-2014
#
# Distributed under the terms of the MIT license.
#
__version__ = '$Id$'
+#
import re
import sys
@@ -257,9 +259,9 @@
family = pywikibot.default_family
# If a site is given instead of a code, use its language
- if hasattr(code, 'lang'):
+ if hasattr(code, 'code'):
family = code.family.name
- code = code.lang
+ code = code.code
# Check whether xdict has multiple projects
if type(xdict) == dict:
@@ -337,8 +339,8 @@
code_needed = False
# If a site is given instead of a code, use its language
- if hasattr(code, 'lang'):
- lang = code.lang
+ if hasattr(code, 'code'):
+ lang = code.code
# check whether we need the language code back
elif type(code) == list:
lang = code.pop()
@@ -363,7 +365,7 @@
break
except KeyError:
continue
- if not trans:
+ if trans is None:
raise TranslationError("No English translation has been defined "
"for TranslateWiki key %r" % twtitle)
# send the language code back via the given list
@@ -402,11 +404,11 @@
},
'nl': {
# format sting inside PLURAL tag is allowed
- 'test-changing': u'Bot: Endrer {{PLURAL:num|1 pagina|%(num)d pagina\'s}}.',
+ 'test-changing': u'Bot: Pas {{PLURAL:num|1 pagina|%(num)d pagina\'s}} aan.',
},
'fr': {
# additional sting inside or outside PLURAL tag is allowed
- 'test-changing': u'Robot: Changer %(descr)s {{PLURAL:num|une page|un peu pages}}.',
+ 'test-changing': u'Robot: Changer %(descr)s {{PLURAL:num|une page|quelques pages}}.',
},
}
#use a number
@@ -419,11 +421,11 @@
>>> i18n.twntranslate('en', 'test-changing', {'num':2})
Bot: Changing 2 pages.
#use additional format strings
- >>> i18n.twntranslate('fr', 'test-changing', {'num':1, 'descr':'seulement'})
- Bot: Changer seulement une pages.
+ >>> i18n.twntranslate('fr', 'test-changing', {'num': 1, 'descr': 'seulement'})
+ Robot: Changer seulement une pages.
#use format strings also outside
- >>> i18n.twntranslate('fr', 'test-changing', 0) % {'descr':'seulement'}
- Bot: Changer seulement un peu pages.
+ >>> i18n.twntranslate('fr', 'test-changing', 10) % {'descr': 'seulement'}
+ Robot: Changer seulement quelques pages.
The translations are retrieved from i18n.<package>, based on the callers
import table.
@@ -433,8 +435,8 @@
if type(parameters) == dict:
param = parameters
# If a site is given instead of a code, use its language
- if hasattr(code, 'lang'):
- code = code.lang
+ if hasattr(code, 'code'):
+ code = code.code
# we send the code via list and get the alternate code back
code = [code]
trans = twtranslate(code, twtitle, None)
@@ -492,8 +494,8 @@
package = twtitle.split("-")[0]
transdict = getattr(__import__("i18n", {}, {}, [package]), package).msg
# If a site is given instead of a code, use its language
- if hasattr(code, 'lang'):
- code = code.lang
+ if hasattr(code, 'code'):
+ code = code.code
return code in transdict and twtitle in transdict[code]
--
To view, visit https://gerrit.wikimedia.org/r/110671
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I519eae0c7c87d790c99c0c21658f87aa98409191
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Andre Engels <andreengels(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Remove obsolete text assignment; other code improvements
......................................................................
Remove obsolete text assignment; other code improvements
- text assigned by Page.get() is never used
- cosmetic_changes are disabled by
config.cosmetic_changes_deny_script list object
- remove obsolete "global" declaration for bot object
Change-Id: Ifdd9f5e74f58d8258ad4bb62986ed9a18b6aeeff
---
M scripts/touch.py
1 file changed, 4 insertions(+), 9 deletions(-)
Approvals:
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/touch.py b/scripts/touch.py
index 6182432..59c21cb 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -17,11 +17,11 @@
will only touch a single page.
"""
#
-# (C) Pywikibot team, 2013
-#
-__version__ = '$Id$'
+# (C) Pywikibot team, 2009-2014
#
# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
#
import pywikibot
@@ -41,7 +41,7 @@
# get the page, and save it using the unmodified text.
# whether or not getting a redirect throws an exception
# depends on the variable self.touch_redirects.
- text = page.get(get_redirect=self.touch_redirects)
+ page.get(get_redirect=self.touch_redirects)
page.save("Pywikibot touch script")
except pywikibot.NoPage:
pywikibot.error(u"Page %s does not exist."
@@ -58,11 +58,6 @@
def main(*args):
- global bot
- # Disable cosmetic changes because we don't want to modify any page
- # content, so that we don't flood the histories with minor changes.
- config.cosmetic_changes = False
- #page generator
gen = None
genFactory = pagegenerators.GeneratorFactory()
redirs = False
--
To view, visit https://gerrit.wikimedia.org/r/119755
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ifdd9f5e74f58d8258ad4bb62986ed9a18b6aeeff
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>