jenkins-bot has submitted this change and it was merged.
Change subject: Add missing docstring to date module
......................................................................
Add missing docstring to date module
Also deprecate/privatise encNoConv and MakeParameter,
which were each only used once in this module.
Change-Id: I21a2a360153c1a0d2bcbebc10f87e95f7380e88b
---
M pywikibot/date.py
M tox.ini
2 files changed, 31 insertions(+), 5 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index dd63890..6e9e8ee 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -85,7 +85,7 @@
#
def dh_noConv(value, pattern, limit):
"""Helper for decoding a single integer value, no conversion, no rounding."""
- return dh(value, pattern, encNoConv, decSinglVal, limit)
+ return dh(value, pattern, lambda i: i, decSinglVal, limit)
def dh_dayOfMnth(value, pattern):
@@ -152,40 +152,48 @@
def dh_number(value, pattern):
+ """Helper for decoding a number."""
return dh_noConv(value, pattern, formatLimits['Number'][0])
def dh_centuryAD(value, pattern):
+ """Helper for decoding an AD century."""
return dh_noConv(value, pattern, formatLimits['CenturyAD'][0])
def dh_centuryBC(value, pattern):
+ """Helper for decoding an BC century."""
return dh_noConv(value, pattern, formatLimits['CenturyBC'][0])
def dh_millenniumAD(value, pattern):
+ """Helper for decoding an AD millennium."""
return dh_noConv(value, pattern, formatLimits['MillenniumAD'][0])
def dh_millenniumBC(value, pattern):
+ """Helper for decoding an BC millennium."""
return dh_noConv(value, pattern, formatLimits['MillenniumBC'][0])
def decSinglVal(v):
+ """Return first item in list v."""
return v[0]
+@deprecated
def encNoConv(i):
+ """Return i."""
return i
def encDec0(i):
- # round to the nearest decade, decade starts with a '0'-ending year
+ """Round to the nearest decade, decade starts with a '0'-ending year."""
return (i // 10) * 10
def encDec1(i):
- # round to the nearest decade, decade starts with a '1'-ending year
+ """Round to the nearest decade, decade starts with a '1'-ending year."""
return encDec0(i) + 1
@@ -212,6 +220,7 @@
def dh_singVal(value, match):
+ """Helper function to match a single value to a constant."""
return dh_constVal(value, 0, match)
@@ -248,6 +257,7 @@
def monthName(lang, ind):
+ """Return the month name for a language."""
return formats['MonthName'][lang](ind)
@@ -278,11 +288,12 @@
def intToLocalDigitsStr(value, digitsToLocalDict):
- # Encode an integer value into a textual form.
+ """Encode an integer value into a textual form."""
return unicode(value).translate(digitsToLocalDict)
def localDigitsStrToInt(value, digitsToLocalDict, localToDigitsDict):
+ """Convert digits to integer."""
# First make sure there are no real digits in the string
tmp = value.translate(digitsToLocalDict) # Test
if tmp == value:
@@ -301,12 +312,14 @@
def intToRomanNum(i):
+ """Convert integer to roman numeral."""
if i >= len(_romanNumbers):
raise IndexError(u'Roman value %i is not defined' % i)
return _romanNumbers[i]
def romanNumToInt(v):
+ """Convert roman numeral to integer."""
return _romanNumbers.index(v)
# Each tuple must 3 parts: a list of all possible digits (symbols), encoder
@@ -457,6 +470,9 @@
params = encf(value)
+ # name 'MakeParameter' kept to avoid breaking blame below
+ MakeParameter = _make_parameter
+
if type(params) in _listTypes:
if len(params) != len(decoders):
raise AssertionError(
@@ -475,7 +491,7 @@
return strPattern % MakeParameter(decoders[0], params)
-def MakeParameter(decoder, param):
+def _make_parameter(decoder, param):
newValue = decoder[1](param)
if len(decoder) == 4 and len(newValue) < decoder[3]:
# force parameter length by taking the first digit in the list and
@@ -483,6 +499,12 @@
# This converts "205" into "0205" for "%4d"
newValue = decoder[0][0] * (decoder[3] - len(newValue)) + newValue
return newValue
+
+
+@deprecated
+def MakeParameter(decoder, param):
+ """DEPRECATED."""
+ return _make_parameter(decoder, param)
#
# All years/decades/centuries/millenniums are designed in such a way
@@ -1964,11 +1986,13 @@
def addFmt2(lang, isMnthOfYear, pattern, makeUpperCase=None):
+ """Update yrMnthFmts and dayMnthFmts using addFmt1."""
addFmt1(lang, isMnthOfYear,
makeMonthNamedList(lang, pattern, makeUpperCase))
def makeMonthList(pattern):
+ """Return a list of 12 elements based on the number of the month."""
return [pattern % m for m in range(1, 13)]
@@ -2370,6 +2394,7 @@
def formatYear(lang, year):
+ """Return year name in a language."""
if year < 0:
return formats['YearBC'][lang](-year)
else:
diff --git a/tox.ini b/tox.ini
index e4b43ee..3a8b968 100644
--- a/tox.ini
+++ b/tox.ini
@@ -64,6 +64,7 @@
pywikibot/config2.py \
pywikibot/daemonize.py \
pywikibot/data/ \
+ pywikibot/date.py \
pywikibot/diff.py \
pywikibot/echo.py \
pywikibot/editor.py \
--
To view, visit https://gerrit.wikimedia.org/r/246420
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I21a2a360153c1a0d2bcbebc10f87e95f7380e88b
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
Build Update for wikimedia/pywikibot-core
-------------------------------------
Build: #3027
Status: Passed
Duration: 23 minutes and 10 seconds
Commit: b1f6f39 (2.0)
Author: Fabian Neundorf
Message: [FIX] config: Don't crash on later get_base_dir calls
All module variables starting with only one underscore get deleted after the
module's instantiation and with 2b07db2a the variable to store whether no user
config should be loaded was stored in such a variable and thus deleted so that
when `get_base_dir` was called afterwards it would crash because it is missing.
This patch renames the variable into using two underscores to still hide it's
presence but prevent it from deletion after the instantiation.
Conflicts:
pywikibot/config2.py
Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
(cherry picked from commit c29a59f95803f517f0fb9a999b59db94b7085404)
View the changeset: https://github.com/wikimedia/pywikibot-core/compare/408312706088...b1f6f390…
View the full build log and details: https://travis-ci.org/wikimedia/pywikibot-core/builds/85823547
--
You can configure recipients for build notifications in your .travis.yml file. See http://docs.travis-ci.com/user/notifications
jenkins-bot has submitted this change and it was merged.
Change subject: Prevent network activity during Jenkins nose tests
......................................................................
Prevent network activity during Jenkins nose tests
Jenkins nose tests should not use http, and the test framework
attempts to ensure network activity is declared so that tests
needing network activity can be skipped.
However it is possible to bypass the test framework by declaring
a test class does not use the network.
Adding nose plugin detecthttp detects and prevents network activity.
api.py doctests initiated network activity.
Also use '!net' instead of "!net", so the command can be run
on the bash command line without '!' being interpreted by bash.
Bug: T115322
Change-Id: I863c1427a233e74445524ae88fd1df5bd5dc4099
---
M tox.ini
1 file changed, 5 insertions(+), 3 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tox.ini b/tox.ini
index 529dd3d..b8328bc 100644
--- a/tox.ini
+++ b/tox.ini
@@ -9,7 +9,7 @@
envlist = flake8,flake8-py3,flake8-docstrings-mandatory
[params]
-nose_skip = --ignore-files=(gui\.py|botirc\.py|rcstream\.py)
+nose_skip = --ignore-files=(gui\.py|botirc\.py|rcstream\.py|api\.py)
flake8_ignore = D102,D103,{[flake8]ignore}
[testenv]
@@ -217,9 +217,10 @@
commands =
python -W error::UserWarning -m generate_user_files -family:test -lang:test -v
nosetests --version
- nosetests --with-doctest -v -a "!net" tests pywikibot {[params]nose_skip}
+ nosetests --with-doctest --with-detecthttp -v -a '!net' tests pywikibot {[params]nose_skip}
deps =
nose
+ nose-detecthttp
unicodecsv
[testenv:nose34]
@@ -227,9 +228,10 @@
commands =
python -W error::UserWarning -m generate_user_files -family:test -lang:test -v
nosetests --version
- nosetests --with-doctest -v -a "!net" tests pywikibot {[params]nose_skip}
+ nosetests --with-doctest --with-detecthttp -v -a '!net' tests pywikibot {[params]nose_skip}
deps =
nose
+ nose-detecthttp>=0.1.3 # Python 3 support added
six
[testenv:venv]
--
To view, visit https://gerrit.wikimedia.org/r/246135
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I863c1427a233e74445524ae88fd1df5bd5dc4099
Gerrit-PatchSet: 7
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: JanZerebecki <jan.wikimedia(a)zerebecki.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] config: Don't crash on later get_base_dir calls
......................................................................
[FIX] config: Don't crash on later get_base_dir calls
All module variables starting with only one underscore get deleted after the
module's instantiation and with 2b07db2a the variable to store whether no user
config should be loaded was stored in such a variable and thus deleted so that
when `get_base_dir` was called afterwards it would crash because it is missing.
This patch renames the variable into using two underscores to still hide it's
presence but prevent it from deletion after the instantiation.
Conflicts:
pywikibot/config2.py
Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
(cherry picked from commit c29a59f95803f517f0fb9a999b59db94b7085404)
---
M pywikibot/config2.py
1 file changed, 8 insertions(+), 8 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index f9dcab8..f2d644f 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -60,9 +60,9 @@
# names and some magic variables (like __name__)
_imports = frozenset(name for name in globals() if not name.startswith('_'))
-_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
-if _no_user_config == '0':
- _no_user_config = None
+__no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
+if __no_user_config == '0':
+ __no_user_config = None
class _ConfigurationDeprecationWarning(UserWarning):
@@ -297,8 +297,8 @@
# check if user-config.py is in base_dir
if not exists(base_dir):
exc_text = "No user-config.py found in directory '%s'.\n" % base_dir
- if _no_user_config:
- if _no_user_config != '2':
+ if __no_user_config:
+ if __no_user_config != '2':
print(exc_text)
else:
exc_text += " Please check that user-config.py is stored in the correct location.\n"
@@ -905,8 +905,8 @@
# Get the user files
_thislevel = 0
-if _no_user_config:
- if _no_user_config != '2':
+if __no_user_config:
+ if __no_user_config != '2':
print("WARNING: Skipping loading of user-config.py.")
_fns = []
else:
@@ -1004,7 +1004,7 @@
# Fix up default site
-if family == 'wikipedia' and mylang == 'language' and _no_user_config != '2':
+if family == 'wikipedia' and mylang == 'language' and __no_user_config != '2':
print("WARNING: family and mylang are not set.\n"
"Defaulting to family='test' and mylang='test'.")
family = mylang = 'test'
--
To view, visit https://gerrit.wikimedia.org/r/246942
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: 2.0
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] config: Don't crash on later get_base_dir calls
......................................................................
[FIX] config: Don't crash on later get_base_dir calls
All module variables starting with only one underscore get deleted after the
module's instantiation and with 2b07db2a the variable to store whether no user
config should be loaded was stored in such a variable and thus deleted so that
when `get_base_dir` was called afterwards it would crash because it is missing.
This patch renames the variable into using two underscores to still hide it's
presence but prevent it from deletion after the instantiation.
Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
---
M pywikibot/config2.py
1 file changed, 8 insertions(+), 8 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 4cac315..8fd624e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -70,9 +70,9 @@
# names and some magic variables (like __name__)
_imports = frozenset(name for name in globals() if not name.startswith('_'))
-_no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
-if _no_user_config == '0':
- _no_user_config = None
+__no_user_config = os.environ.get('PYWIKIBOT2_NO_USER_CONFIG')
+if __no_user_config == '0':
+ __no_user_config = None
class _ConfigurationDeprecationWarning(UserWarning):
@@ -323,8 +323,8 @@
# check if user-config.py is in base_dir
if not exists(base_dir):
exc_text = "No user-config.py found in directory '%s'.\n" % base_dir
- if _no_user_config:
- if _no_user_config != '2':
+ if __no_user_config:
+ if __no_user_config != '2':
output(exc_text)
else:
exc_text += " Please check that user-config.py is stored in the correct location.\n"
@@ -935,8 +935,8 @@
# Get the user files
_thislevel = 0
-if _no_user_config:
- if _no_user_config != '2':
+if __no_user_config:
+ if __no_user_config != '2':
warning('Skipping loading of user-config.py.')
_fns = []
else:
@@ -1072,7 +1072,7 @@
# Fix up default site
if family == 'wikipedia' and mylang == 'language':
- if _no_user_config != '2':
+ if __no_user_config != '2':
warning('family and mylang are not set.\n'
"Defaulting to family='test' and mylang='test'.")
family = mylang = 'test'
--
To view, visit https://gerrit.wikimedia.org/r/246853
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I538a73ff37da27a34ab732becafbf5a58b72a464
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix script test for imageharvest simulate
......................................................................
Fix script test for imageharvest simulate
imageharvest uses BeautifulSoup version 3, which is not
installed by setup (T115428).
When BeautifulSoup version 3 is installed, the script test
for imageharvest hangs waiting for input.
Providing a url for the script allows it to load and exit cleanly.
Change-Id: I8f85dae4a2589d5c03fe6151530f13e00e402e90
---
M tests/script_tests.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 4f58633..090ebc1 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -94,6 +94,7 @@
'catall': 'q\n', # q for quit
'editarticle': 'Test page\n',
'imageuncat': 'q\n',
+ 'imageharvest': 'https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg\n…',
'interwiki': 'Test page that should not exist\n',
'misspelling': 'q\n',
'pagefromfile': 'q\n',
--
To view, visit https://gerrit.wikimedia.org/r/246126
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8f85dae4a2589d5c03fe6151530f13e00e402e90
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix ProofreadPage RST error
......................................................................
Fix ProofreadPage RST error
Change-Id: Iec8b38a41e77dfc8b6cf61bfa0a7d2ae635ac035
---
M pywikibot/proofreadpage.py
1 file changed, 8 insertions(+), 4 deletions(-)
Approvals:
XZise: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/proofreadpage.py b/pywikibot/proofreadpage.py
index d27b08b..5d0e9ba 100644
--- a/pywikibot/proofreadpage.py
+++ b/pywikibot/proofreadpage.py
@@ -5,6 +5,7 @@
The extension is supported by MW 1.21+.
This module includes objects:
+
* ProofreadPage(Page)
* FullHeader
* IndexPage(Page)
@@ -105,12 +106,15 @@
def index(self):
"""Get the Index page which contains ProofreadPage.
+ If there are many Index pages link to this ProofreadPage, and
+ the ProofreadPage is titled Page:<index title>/<page number>,
+ the Index page with the same title will be returned.
+ Otherwise None is returned in the case of multiple linked Index pages.
+
To force reload, delete index and call it again.
- Returns:
- None: if ProofreadPage is linked to no or several Index pages
- and no inerence can be done from titles.
- IndexPage: if ProofreadPage is linked to one Index page.
+ @return: the Index page for this ProofreadPage
+ @rtype: IndexPage or None
"""
if not hasattr(self, '_index'):
index_ns = self.site.proofread_index_ns
--
To view, visit https://gerrit.wikimedia.org/r/246814
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec8b38a41e77dfc8b6cf61bfa0a7d2ae635ac035
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>