Merlijn van Deen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76529
Change subject: pep8-ify pywikibot/version.py
......................................................................
pep8-ify pywikibot/version.py
Change-Id: Ia4d7e7009ebbf2416cc1487d9e079d2d8f06f1f9
---
M pywikibot/version.py
1 file changed, 18 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/29/76529/1
diff --git a/pywikibot/version.py b/…
[View More]pywikibot/version.py
index 431fe2e..9d23b12 100644
--- a/pywikibot/version.py
+++ b/pywikibot/version.py
@@ -15,8 +15,10 @@
cache = None
+
class ParseError(Exception):
""" Parsing went wrong """
+
def _get_program_dir():
_program_dir = os.path.normpath(os.path.split(os.path.dirname(__file__))[0])
@@ -24,6 +26,7 @@
## if not os.path.isabs(_program_dir):
## _program_dir = os.path.normpath(os.path.join(os.getcwd(), _program_dir))
return _program_dir
+
def getversion():
data = getversiondict()
@@ -35,10 +38,11 @@
data['cmp_ver'] = 'n/a'
return '%(tag)s (r%(rev)s, %(date)s, %(cmp_ver)s)' % data
+
def getversiondict():
global cache
if cache:
- return cache
+ return cache
try:
(tag, rev, date) = getversion_svn()
except Exception:
@@ -55,7 +59,8 @@
id, file, rev, date, ts, author, dollar = version.split(' ')
tag = 'pywikibot/__init__.py'
date = time.strptime('%sT%s' % (date, ts), '%Y-%m-%dT%H:%M:%SZ')
- except: # nothing worked; version unknown (but suppress exceptions)
+ except:
+ # nothing worked; version unknown (but suppress exceptions)
# the value is most likely '$Id' + '$', it means that
# wikipedia.py got imported without using svn at all
return dict(tag='', rev='-1 (unknown)', date='0 (unknown)')
@@ -63,6 +68,7 @@
datestring = time.strftime('%Y/%m/%d, %H:%M:%S', date)
cache = dict(tag=tag, rev=rev, date=datestring)
return cache
+
def getversion_svn(path=None):
_program_dir = path or _get_program_dir()
@@ -74,7 +80,7 @@
from sqlite3 import dbapi2 as sqlite
con = sqlite.connect(os.path.join(_program_dir, ".svn/wc.db"))
cur = con.cursor()
- cur.execute( '''select local_relpath, repos_path, revision, changed_date from nodes order by revision desc, changed_date desc''')
+ cur.execute('''select local_relpath, repos_path, revision, changed_date from nodes order by revision desc, changed_date desc''')
name, tag, rev, date = cur.fetchone()
con.close()
tag = tag[:-len(name)]
@@ -88,25 +94,26 @@
tag = '[%s] %s' % (t[0], t[1])
for i in xrange(4):
entries.readline()
- date = time.strptime(entries.readline()[:19],'%Y-%m-%dT%H:%M:%S')
+ date = time.strptime(entries.readline()[:19], '%Y-%m-%dT%H:%M:%S')
rev = entries.readline()[:-1]
entries.close()
if (not date or not tag or not rev) and not path:
raise ParseError
return (tag, rev, date)
+
def getversion_nightly():
data = open(os.path.join(wikipediatools.get_base_dir(), 'version'))
tag = data.readline().strip()
- date = time.strptime(data.readline()[:19],'%Y-%m-%dT%H:%M:%S')
+ date = time.strptime(data.readline()[:19], '%Y-%m-%dT%H:%M:%S')
rev = data.readline().strip()
if not date or not tag or not rev:
raise ParseError
return (tag, rev, date)
-## Retrieve revision number of framework online repository's svnroot
-#
+
def getversion_onlinerepo(repo=None):
+ """ Retrieve revision number of framework online repository's svnroot """
url = repo or 'http://svn.wikimedia.org/svnroot/pywikipedia/trunk/pywikipedia/'
rev = None
try:
@@ -120,10 +127,11 @@
#
cmp_ver = lambda a, b, tol=1: {-1: '<', 0: '~', 1: '>'}[cmp((a-b)//tol, 0)]
-## Retrieve revision number of file (__version__ variable containing Id tag)
-# without importing it (thus can be done for any file)
-#
+
def getfileversion(filename):
+ """ Retrieve revision number of file (__version__ variable containing Id tag)
+ without importing it (thus can be done for any file)
+ """
_program_dir = _get_program_dir()
__version__ = None
fn = os.path.join(_program_dir, filename)
--
To view, visit https://gerrit.wikimedia.org/r/76529
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia4d7e7009ebbf2416cc1487d9e079d2d8f06f1f9
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
[View Less]
Merlijn van Deen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76521
Change subject: Removed commented-out zh templates
......................................................................
Removed commented-out zh templates
There is no reason to have commented-out templates in source control.
Change-Id: Iaf3740fabb0f196748ba7541e1db601bdc804104
---
M scripts/blockpageschecker.py
1 file changed, 0 insertions(+), 5 deletions(-)
git pull ssh://gerrit.wikimedia.…
[View More]org:29418/pywikibot/core refs/changes/21/76521/1
diff --git a/scripts/blockpageschecker.py b/scripts/blockpageschecker.py
index 8d8f23e..1507348 100755
--- a/scripts/blockpageschecker.py
+++ b/scripts/blockpageschecker.py
@@ -85,7 +85,6 @@
r'\{\{(?:[Tt]emplate:|)[Aa]bp(?:|[ _]scad\|(?:.*?))\}\}'],
'fr': [ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Ss]emi[- ]?protection(|[^\}]*)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)半保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- #'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Ss]|[Ss]emi|半)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the total-protection template
templateTotalProtection = {
@@ -95,21 +94,18 @@
'fr':[ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)[Pp]rotection(|[^\}]*)\}\}',
ur'\{\{(?:[Tt]emplate:|[Mm]odèle:|)(?:[Pp]age|[Aa]rchive|[Mm]odèle) protégée?(|[^\}]*)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)保護(?:性急|)(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- #'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Nn]|[Nn]ormal)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the semi-protection move template
templateSemiMoveProtection = {
'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[ _]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動半保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- #'zh':[r'\{\{(?:[Tt]emplate:|)Protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Mini-protected|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)',r'\{\{(?:[Tt]emplate:|)Protected-logo|(?:MS|ms)(?:\|.+|)\}\}(\n+?|)'],
}
# Regex to get the total-protection move template
templateTotalMoveProtection = {
'en': None,
'it':[r'\{\{(?:[Tt]emplate:|)[Aa]vvisobloccospostamento(?:|[ _]scad\|.*?|\|.*?)\}\}'],
'ja':[ur'(?<!\<nowiki\>)\{\{(?:[Tt]emplate:|)移動保護(?:[Ss]|)(?:\|.+|)\}\}(?!\<\/nowiki\>)\s*(?:\r\n|)*'],
- #'zh':[ur'\{\{(?:[Tt]emplate:|)Protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Mini-protected|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)',ur'\{\{(?:[Tt]emplate:|)Protected-logo|(?:[Mm]|[Mm]ove|移[動动])(?:\|.+|)\}\}(\n+?|)'],
}
# If you use only one template for all the type of protection, put it here.
@@ -125,7 +121,6 @@
'it':['{{Avvisobloccoparziale}}', '{{Avvisoblocco}}', None, None, '{{Protetta}}'],
'fr':['{{Semi-protection}}', '{{Protection}}', None, None, None],
'ja':[u'{{半保護}}', u'{{保護}}', u'{{移動半保護}}', u'{{移動保護}}', None],
- #'zh':[u'{{Protected/semi}}',u'{{Protected}}',u'{{Protected/ms}}',u'{{Protected/move}}', None],
}
# Category where the bot will check
--
To view, visit https://gerrit.wikimedia.org/r/76521
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Iaf3740fabb0f196748ba7541e1db601bdc804104
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
[View Less]
Merlijn van Deen has uploaded a new change for review.
https://gerrit.wikimedia.org/r/76519
Change subject: Add initial .pep8 configuration file
......................................................................
Add initial .pep8 configuration file
Max line length is set to 256 - this is too long, but there are
*a lot* of scripts with very long lines. This allows us to fix the
most important ones first.
distribute_setup.py is externally-delivered and is thus ignored
externals/* …
[View More]should be ignored
user-config.py also should be ignored
all i18n files and date.py are basically databases-in-python-format
and therefore are exempt from pep8 rules
Change-Id: I1bba208a9277dbcacb0e2c2001e2dc3252e4b21b
---
A .pep8
1 file changed, 3 insertions(+), 0 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core refs/changes/19/76519/1
diff --git a/.pep8 b/.pep8
new file mode 100644
index 0000000..4827278
--- /dev/null
+++ b/.pep8
@@ -0,0 +1,3 @@
+[pep8]
+exclude = distribute_setup.py,externals,user-config.py,./scripts/i18n/*,./pywikibot/date.py
+max_line_length = 256
--
To view, visit https://gerrit.wikimedia.org/r/76519
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1bba208a9277dbcacb0e2c2001e2dc3252e4b21b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
[View Less]
jenkins-bot has submitted this change and it was merged.
Change subject: RotatingFileHandler: Let the docstring make sense
......................................................................
RotatingFileHandler: Let the docstring make sense
Having files "app.2.log" and "app.2.log" didn't.
Change-Id: If96617cf7026ca33fded34e8a1f19db882f9b54f
---
M pywikibot/bot.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: …
[View More]Verified
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 4424cb9..355dfec 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -55,8 +55,8 @@
"app.log", you would get "app.log", "app.1.log", "app.2.log", ...
through to "app.5.log". The file being written to is always "app.log" -
when it gets filled up, it is closed and renamed to "app.1.log", and if
- files "app.2.log", "app.2.log" etc. exist, then they are renamed to
- "app.2.log", "app.3.log" etc. respectively.
+ files "app.1.log", "app.2.log" etc. already exist, then they are
+ renamed to "app.2.log", "app.3.log" etc. respectively.
If backupCount is >= 1 do not rotate but create new numbered filenames.
The newest file has the highest number except some older numbered files
where deleted and the bot was restarted. In this case the ordering
--
To view, visit https://gerrit.wikimedia.org/r/76488
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If96617cf7026ca33fded34e8a1f19db882f9b54f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Mineo <themineo(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot
[View Less]