jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/563974 )
Change subject: [cleanup] Cleanup sysopnames in config2.py
......................................................................
[cleanup] Cleanup sysopnames in config2.py
config.sysopnames is deprecated since 6f0cafd
- documentation about sysopnames
- move sysopnames to obsolete section
- do not assign families to sysopnames in register_family_file
Change-Id: I43ca15fdb9db60fb65d81354931e80548499fc2a
---
M pywikibot/config2.py
1 file changed, 2 insertions(+), 13 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 69972e3..08de9c4 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -33,7 +33,7 @@
"""
#
# (C) Rob W.W. Hooft, 2003
-# (C) Pywikibot team, 2003-2019
+# (C) Pywikibot team, 2003-2020
#
# Distributed under the terms of the MIT license.
#
@@ -137,18 +137,7 @@
# usernames['wikibooks']['*'] = 'mySingleUsername'
# You may use '*' for family name in a similar manner.
#
-# If you have a sysop account on some wikis, this will be used to delete pages
-# or to edit locked pages if you add such lines to your
-# user-config.py:
-#
-# sysopnames['wikipedia']['de'] = 'myGermanUsername'
-# sysopnames['wiktionary']['en'] = 'myEnglishUsername'
-#
-# If you have a unique syop account for all languages of a family,
-# you can use '*'
-# sysopnames['myownwiki']['*'] = 'mySingleUsername'
usernames = collections.defaultdict(dict)
-sysopnames = collections.defaultdict(dict)
disambiguation_comment = collections.defaultdict(dict)
# User agent format.
@@ -410,7 +399,6 @@
family.AutoFamily function is used when the url is given.
"""
usernames[family_name] = {}
- sysopnames[family_name] = {}
disambiguation_comment[family_name] = {}
family_files[family_name] = file_path
@@ -931,6 +919,7 @@
}
special_page_limit = 500
+sysopnames = collections.defaultdict(dict)
# #############################################
--
To view, visit https://gerrit.wikimedia.org/r/563974
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I43ca15fdb9db60fb65d81354931e80548499fc2a
Gerrit-Change-Number: 563974
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/563973 )
Change subject: [cleanup] Cleanup sysop option in watchlist.py
......................................................................
[cleanup] Cleanup sysop option in watchlist.py
config.sysopnames is deprecated since 6f0cafd
- Remove undocumented -sysop option
- rename option variables
Change-Id: Idd35db2937629247351f45a3e26a4f0b09d59248
---
M scripts/watchlist.py
1 file changed, 16 insertions(+), 26 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/watchlist.py b/scripts/watchlist.py
index 298de83..08fd6cf 100755
--- a/scripts/watchlist.py
+++ b/scripts/watchlist.py
@@ -18,7 +18,7 @@
"""
#
# (C) Daniel Herding, 2005
-# (C) Pywikibot team, 2005-2019
+# (C) Pywikibot team, 2005-2020
#
# Distributed under the terms of the MIT license.
#
@@ -27,11 +27,8 @@
import os
import pywikibot
-
from pywikibot import config
-
from pywikibot.data.api import CachedRequest
-
from scripts.maintenance.cache import CacheEntry
@@ -49,13 +46,13 @@
return pageName in watchlist
-def refresh(site, sysop=False):
+def refresh(site):
"""Fetch the watchlist."""
pywikibot.output('Retrieving watchlist for {0}.'.format(str(site)))
- return list(site.watched_pages(sysop=sysop, force=True))
+ return list(site.watched_pages(force=True))
-def refresh_all(sysop=False):
+def refresh_all():
"""Reload watchlists for all wikis where a watchlist is already present."""
cache_path = CachedRequest._get_cache_dir()
files = os.listdir(cache_path)
@@ -66,22 +63,18 @@
entry.parse_key()
entry._rebuild()
if entry.site not in seen and 'watchlistraw' in entry._data:
- refresh(entry.site, sysop)
+ refresh(entry.site)
seen.add(entry.site)
-def refresh_new(sysop=False):
+def refresh_new():
"""Load watchlists of all wikis for accounts set in user-config.py."""
pywikibot.output(
'Downloading all watchlists for your accounts in user-config.py')
for family in config.usernames:
for lang in config.usernames[family]:
site = pywikibot.Site(lang, family)
- refresh(site, sysop=sysop)
- for family in config.sysopnames:
- for lang in config.sysopnames[family]:
- site = pywikibot.Site(lang, family)
- refresh(site, sysop=sysop)
+ refresh(site)
def main(*args):
@@ -93,23 +86,20 @@
@param args: command line arguments
@type args: str
"""
- all = False
- new = False
- sysop = False
+ opt_all = False
+ opt_new = False
for arg in pywikibot.handle_args(args):
if arg in ('-all', '-update'):
- all = True
+ opt_all = True
elif arg == '-new':
- new = True
- elif arg == '-sysop':
- sysop = True
- if all:
- refresh_all(sysop=sysop)
- elif new:
- refresh_new(sysop=sysop)
+ opt_new = True
+ if opt_all:
+ refresh_all()
+ elif opt_new:
+ refresh_new()
else:
site = pywikibot.Site()
- watchlist = refresh(site, sysop=sysop)
+ watchlist = refresh(site)
pywikibot.output('{} pages in the watchlist.'.format(len(watchlist)))
for page in watchlist:
try:
--
To view, visit https://gerrit.wikimedia.org/r/563973
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Idd35db2937629247351f45a3e26a4f0b09d59248
Gerrit-Change-Number: 563973
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/563400 )
Change subject: [doc] Update docs for setup.py
......................................................................
[doc] Update docs for setup.py
- remove pwb version on top to prevents to change
this doc with every release
- additional doc for get_version function
- only split the first space in git log entry for date sting
Change-Id: Iba895d86d6ced89d40ae0a77d5cfe8cd06aa93ec
---
M setup.py
1 file changed, 10 insertions(+), 3 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/setup.py b/setup.py
index 69e12d7..aadfda7 100644
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
-"""Installer script for Pywikibot 3.0 framework."""
+"""Installer script for Pywikibot framework."""
#
# (C) Pywikibot team, 2009-2020
#
@@ -165,13 +165,20 @@
def get_version(name):
- """Get a valid pywikibot module version string."""
+ """Get a valid pywikibot module version string.
+
+ Either create a timebased version number for the package
+ or read the version number from the package.
+
+ @return: pywikibot module version string
+ @rtype: str
+ """
version = '3.0'
try:
import subprocess
date = subprocess.check_output(
['git', 'log', '-1', '--format=%ci']).strip()
- date = date.decode().split(' ')[0].replace('-', '')
+ date = date.decode().split(' ', 1)[0].replace('-', '')
version += '.' + date
if 'sdist' not in sys.argv:
version += '.dev0'
--
To view, visit https://gerrit.wikimedia.org/r/563400
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iba895d86d6ced89d40ae0a77d5cfe8cd06aa93ec
Gerrit-Change-Number: 563400
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/516636 )
Change subject: [bugfix] Test all packages with l10n_tests.py
......................................................................
[bugfix] Test all packages with l10n_tests.py
- add package parameter to test_method all packages
- use i18n.twhas_key to verify that a translation message exists;
otherwise a TranslationError will be raised
- skip tests on some sites where these aren't applicable
Bug: T225631
Bug: T225781
Change-Id: I13ec0f1761db95a50c1a871659fdea52cc3ce2d0
---
M tests/l10n_tests.py
1 file changed, 30 insertions(+), 23 deletions(-)
Approvals:
Huji: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py
index 52bb522..e398f51 100644
--- a/tests/l10n_tests.py
+++ b/tests/l10n_tests.py
@@ -28,35 +28,42 @@
def __new__(cls, name, bases, dct):
"""Create the new class."""
- def test_method(site):
+ def test_method(site, package):
def test_template(self):
"""Test validity of template."""
lang = site.lang
if lang not in keys:
return
- msg = i18n.twtranslate(lang, package, fallback=False)
- if msg:
- # check whether the message contains a template
- templates = extract_templates_and_params_regex_simple(msg)
- self.assertIsInstance(templates, list)
- self.assertIsNotEmpty(templates)
- # known problem
- if site.code == 'simple':
- raise unittest.SkipTest(
- "'simple' wiki has 'en' language code but "
- 'missing template. Must be solved by the '
- 'corresponding script.')
- # check whether template exists
- title = templates[0][0]
- page = pywikibot.Page(site, title, ns=10)
- self.assertTrue(
- page.exists(),
- msg='Invalid L10N in package "{package}"\n'
- 'template "{title}" does not exist for lang '
- '"{site.lang}" on site "{site}"'
- .format(package=package, title=title, site=site))
+ if not i18n.twhas_key(lang, package):
+ return
+
+ msg = i18n.twtranslate(lang, package, fallback=False)
+
+ # check whether the message contains a template
+ templates = extract_templates_and_params_regex_simple(msg)
+ self.assertIsInstance(templates, list)
+ self.assertIsNotEmpty(templates)
+
+ # known problems
+ if (package == PACKAGES[0] and site.code in ['simple', 'test2']
+ or package == PACKAGES[1] and site.code == 'test'):
+ raise unittest.SkipTest(
+ "{site} wiki has '{site.lang}' language code but "
+ "missing template for package '{package}'. Must be "
+ 'solved by the corresponding script.'
+ .format(site=site, package=package))
+
+ # check whether template exists
+ title = templates[0][0]
+ page = pywikibot.Page(site, title, ns=10)
+ self.assertTrue(
+ page.exists(),
+ msg='Invalid L10N in package "{package}"\n'
+ 'template "{title}" does not exist for lang '
+ '"{site.lang}" on site "{site}"'
+ .format(package=package, title=title, site=site))
return test_template
@@ -75,7 +82,7 @@
test_name = ('test_{}_{}'
.format(package, code)).replace('-', '_')
cls.add_method(
- dct, test_name, test_method(current_site),
+ dct, test_name, test_method(current_site, package),
doc_suffix='{0} and language {1}'.format(
package, code))
--
To view, visit https://gerrit.wikimedia.org/r/516636
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I13ec0f1761db95a50c1a871659fdea52cc3ce2d0
Gerrit-Change-Number: 516636
Gerrit-PatchSet: 4
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/563683 )
Change subject: Deprecate Category.copyTo and Category.copyAndKeep methods
......................................................................
Deprecate Category.copyTo and Category.copyAndKeep methods
- Both were imported from compat's catlib.py.
- Both are not used in core and are too specialized.
- scripts/category.py has _strip_cfd_templates, which provides similar
functionality when it is needed there.
Change-Id: I81000f4db448feb837a287ea6355ce48e7d1169e
---
M HISTORY.rst
M pywikibot/page.py
2 files changed, 88 insertions(+), 85 deletions(-)
Approvals:
Xqt: Looks good to me, but someone else must approve
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index dd4a38b..c189bdb 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,7 @@
Current release
---------------
+* Category.copyTo and Category.copyAndKeep will be removed in the next release
* botirc module has been removed (T212632)
* Bugfixes and improvements
* Localisation updates
diff --git a/pywikibot/page.py b/pywikibot/page.py
index e96b27b..44d0a82 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3033,91 +3033,6 @@
"""
return 'hiddencat' in self.properties()
- def copyTo(self, cat, message):
- """
- Copy text of category page to a new page. Does not move contents.
-
- @param cat: New category title (without namespace) or Category object
- @type cat: str or pywikibot.page.Category
- @param message: message to use for category creation message
- If two %s are provided in message, will be replaced
- by (self.title, authorsList)
- @type message: str
- @return: True if copying was successful, False if target page
- already existed.
- @rtype: bool
- """
- # This seems far too specialized to be in the top-level framework
- # move to category.py? (Although it doesn't seem to be used there,
- # either)
- if not isinstance(cat, Category):
- target_cat = Category(self.site, 'Category:' + cat)
- else:
- target_cat = cat
- if target_cat.exists():
- pywikibot.warning(
- 'Target page %s already exists!' % target_cat.title())
- return False
- else:
- pywikibot.output('Moving text from %s to %s.'
- % (self.title(), target_cat.title()))
- authors = ', '.join(self.contributingUsers())
- try:
- creation_summary = message % (self.title(), authors)
- except TypeError:
- creation_summary = message
- target_cat.put(self.get(), creation_summary)
- return True
-
- @deprecated_args(cfdTemplates='cfd_templates')
- def copyAndKeep(self, catname, cfd_templates, message):
- """
- Copy partial category page text (not contents) to a new title.
-
- Like copyTo above, except this removes a list of templates (like
- deletion templates) that appear in the old category text. It also
- removes all text between the two HTML comments BEGIN CFD TEMPLATE
- and END CFD TEMPLATE. (This is to deal with CFD templates that are
- substituted.)
-
- Returns true if copying was successful, false if target page already
- existed.
-
- @param catname: New category title (without namespace)
- @param cfd_templates: A list (or iterator) of templates to be removed
- from the page text
- @return: True if copying was successful, False if target page
- already existed.
- @rtype: bool
- """
- # I don't see why we need this as part of the framework either
- # move to scripts/category.py?
- target_cat = Category(self.site, 'Category:' + catname)
- if target_cat.exists():
- pywikibot.warning('Target page %s already exists!'
- % target_cat.title())
- return False
-
- pywikibot.output(
- 'Moving text from {} to {}.'
- .format(self.title(), target_cat.title()))
- authors = ', '.join(self.contributingUsers())
- creation_summary = message % (self.title(), authors)
- newtext = self.get()
- for regex_name in cfd_templates:
- matchcfd = re.compile(r'{{%s.*?}}' % regex_name, re.IGNORECASE)
- newtext = matchcfd.sub('', newtext)
- matchcomment = re.compile(
- r'<!--BEGIN CFD TEMPLATE-->.*?<!--END CFD TEMPLATE-->',
- re.IGNORECASE | re.MULTILINE | re.DOTALL)
- newtext = matchcomment.sub('', newtext)
- pos = 0
- while (newtext[pos:pos + 1] == '\n'):
- pos = pos + 1
- newtext = newtext[pos:]
- target_cat.put(newtext, creation_summary)
- return True
-
@property
def categoryinfo(self):
"""
@@ -3225,6 +3140,93 @@
"""DEPRECATED: equivalent to list(self.categories(...))."""
return sorted(set(self.categories()))
+ @deprecated(since='20200111', future_warning=True)
+ def copyTo(self, cat, message):
+ """
+ Copy text of category page to a new page. Does not move contents.
+
+ @param cat: New category title (without namespace) or Category object
+ @type cat: str or pywikibot.page.Category
+ @param message: message to use for category creation message
+ If two %s are provided in message, will be replaced
+ by (self.title, authorsList)
+ @type message: str
+ @return: True if copying was successful, False if target page
+ already existed.
+ @rtype: bool
+ """
+ # This seems far too specialized to be in the top-level framework
+ # move to category.py? (Although it doesn't seem to be used there,
+ # either)
+ if not isinstance(cat, Category):
+ target_cat = Category(self.site, 'Category:' + cat)
+ else:
+ target_cat = cat
+ if target_cat.exists():
+ pywikibot.warning(
+ 'Target page %s already exists!' % target_cat.title())
+ return False
+ else:
+ pywikibot.output('Moving text from %s to %s.'
+ % (self.title(), target_cat.title()))
+ authors = ', '.join(self.contributingUsers())
+ try:
+ creation_summary = message % (self.title(), authors)
+ except TypeError:
+ creation_summary = message
+ target_cat.put(self.get(), creation_summary)
+ return True
+
+ @deprecated(since='20200111', future_warning=True)
+ @deprecated_args(cfdTemplates='cfd_templates')
+ def copyAndKeep(self, catname, cfd_templates, message):
+ """
+ Copy partial category page text (not contents) to a new title.
+
+ Like copyTo above, except this removes a list of templates (like
+ deletion templates) that appear in the old category text. It also
+ removes all text between the two HTML comments BEGIN CFD TEMPLATE
+ and END CFD TEMPLATE. (This is to deal with CFD templates that are
+ substituted.)
+
+ Returns true if copying was successful, false if target page already
+ existed.
+
+ @param catname: New category title (without namespace)
+ @param cfd_templates: A list (or iterator) of templates to be removed
+ from the page text
+ @return: True if copying was successful, False if target page
+ already existed.
+ @rtype: bool
+ """
+ # I don't see why we need this as part of the framework either
+ # move to scripts/category.py?
+ target_cat = Category(self.site, 'Category:' + catname)
+ if target_cat.exists():
+ pywikibot.warning('Target page %s already exists!'
+ % target_cat.title())
+ return False
+
+ pywikibot.output(
+ 'Moving text from {} to {}.'
+ .format(self.title(), target_cat.title()))
+ authors = ', '.join(self.contributingUsers())
+ creation_summary = message % (self.title(), authors)
+ newtext = self.get()
+ for regex_name in cfd_templates:
+ matchcfd = re.compile(r'{{%s.*?}}' % regex_name, re.IGNORECASE)
+ newtext = matchcfd.sub('', newtext)
+ matchcomment = re.compile(
+ r'<!--BEGIN CFD TEMPLATE-->.*?<!--END CFD TEMPLATE-->',
+ re.IGNORECASE | re.MULTILINE | re.DOTALL)
+ newtext = matchcomment.sub('', newtext)
+ pos = 0
+ while (newtext[pos:pos + 1] == '\n'):
+ pos = pos + 1
+ newtext = newtext[pos:]
+ target_cat.put(newtext, creation_summary)
+ return True
+
class User(Page):
--
To view, visit https://gerrit.wikimedia.org/r/563683
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I81000f4db448feb837a287ea6355ce48e7d1169e
Gerrit-Change-Number: 563683
Gerrit-PatchSet: 4
Gerrit-Owner: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)