jenkins-bot has submitted this change and it was merged.
Change subject: Fix unicode issues in generate_user_files.py See bug 66242
......................................................................
Fix unicode issues in generate_user_files.py See bug 66242
Change-Id: I3da2636e4e1bc8a9ee855727109230086f8a1c07
---
M generate_user_files.py
1 file changed, 24 insertions(+), 24 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/generate_user_files.py b/generate_user_files.py
index c9cefb1..88bea75 100644
--- a/generate_user_files.py
+++ b/generate_user_files.py
@@ -34,7 +34,7 @@
# copied from config2.py, without the lines that check whether the
# directory already contains a user-config.py file
# this code duplication is nasty, should fix
- NAME = "pywikibot"
+ NAME = u"pywikibot"
for arg in sys.argv[1:]:
if arg.startswith("-dir:"):
base_dir = arg[5:]
@@ -71,15 +71,15 @@
def listchoice(clist=[], message=None, default=None):
if not message:
- message = "Select"
+ message = u"Select"
if default:
- message += " (default: %s)" % default
+ message += u" (default: %s)" % default
- message += ": "
+ message += u": "
for n, i in enumerate(clist):
- print ("%d: %s" % (n + 1, i))
+ print (u"%d: %s" % (n + 1, i))
while True:
choice = raw_input(message)
@@ -128,7 +128,7 @@
break
from textwrap import wrap
- msg = wrap("""WARNING: Your user files will be created in the directory
+ msg = wrap(u"""WARNING: Your user files will be created in the directory
'%(new_base)s' you have chosen. To access these files, you will either have
to use the argument "-dir:%(new_base)s" every time you run the bot, or set
the environment variable "PYWIKIBOT2_DIR" equal to this directory name in
@@ -146,7 +146,7 @@
def file_exists(filename):
if os.path.exists(filename):
- print("'%s' already exists." % filename)
+ print(u"'%s' already exists." % filename)
return True
return False
@@ -161,20 +161,20 @@
)
known_families = sorted(known_families)
fam = listchoice(known_families,
- "Select family of sites we are working on, "
- "just enter the number not name",
- default='wikipedia')
+ u"Select family of sites we are working on, "
+ u"just enter the number not name",
+ default=u'wikipedia')
if fam not in single_wiki_families:
codesds = codecs.open(os.path.join(pywikibot_dir,
- "pywikibot",
- "families",
- "%s_family.py" % fam),
+ u"pywikibot",
+ u"families",
+ u"%s_family.py" % fam),
"r", "utf-8").read()
- rre = re.compile("self\.languages\_by\_size *\= *(.+?)\]",
+ rre = re.compile(u"self\.languages\_by\_size *\= *(.+?)\]",
re.DOTALL)
known_langs = []
if not rre.findall(codesds):
- rre = re.compile("self\.langs *\= *(.+?)\}", re.DOTALL)
+ rre = re.compile(u"self\.langs *\= *(.+?)\}", re.DOTALL)
if rre.findall(codesds):
import ast
known_langs = ast.literal_eval(
@@ -182,13 +182,13 @@
else:
known_langs = eval(rre.findall(codesds)[0] + u"]")
print("This is the list of known language(s):")
- print(" ".join(sorted(known_langs)))
+ print(u" ".join(sorted(known_langs)))
mylang = raw_input("The language code of the site we're working on "
"(default: 'en'): ") or 'en'
else:
mylang = fam
- username = raw_input("Username (%s %s): "
+ username = raw_input(u"Username (%s %s): "
% (mylang, fam))
username = unicode(username, console_encoding)
return fam, mylang, username
@@ -232,7 +232,7 @@
f = codecs.open(_fnc, "w", "utf-8")
if choice == 'E':
- f.write("""# -*- coding: utf-8 -*-
+ f.write(u"""# -*- coding: utf-8 -*-
# This is an automatically generated file. You can find more configuration
# parameters in 'config.py' file.
@@ -278,7 +278,7 @@
%s""" % (fam, mylang, fam, mylang, mainusername, config_text))
else:
- f.write("""# -*- coding: utf-8 -*-
+ f.write(u"""# -*- coding: utf-8 -*-
family = '%s'
mylang = '%s'
usernames['%s']['%s'] = u'%s'
@@ -289,18 +289,18 @@
username = username or mainusername
# Escape ''s
username = username.replace("'", "\\'")
- f.write("usernames['%(fam)s']['%(mylang)s'] = u'%(username)s'\n"
+ f.write(u"usernames['%(fam)s']['%(mylang)s'] = u'%(username)s'\n"
% locals())
f.close()
- print("'%s' written." % _fnc)
+ print(u"'%s' written." % _fnc)
def create_user_fixes():
_fnf = os.path.join(base_dir, "user-fixes.py")
if not file_exists(_fnf):
f = codecs.open(_fnf, "w", "utf-8")
- f.write(r"""# -*- coding: utf-8 -*-
+ f.write(ur"""# -*- coding: utf-8 -*-
#
# This is only an example. Don't use it.
@@ -318,11 +318,11 @@
""")
f.close()
- print("'%s' written." % _fnf)
+ print(u"'%s' written." % _fnf)
if __name__ == "__main__":
while True:
- print('\nYour default user directory is "%s"' % base_dir)
+ print(u'\nYour default user directory is "%s"' % base_dir)
ok = raw_input("How to proceed? ([K]eep [c]hange) ").upper().strip()
if (not ok) or "KEEP".startswith(ok):
break
--
To view, visit https://gerrit.wikimedia.org/r/138118
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3da2636e4e1bc8a9ee855727109230086f8a1c07
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Betacommand <betacommand(a)gmail.com>
Gerrit-Reviewer: Gerrit Patch Uploader <gerritpatchuploader(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: specify family for tests
......................................................................
specify family for tests
test fails if user-config.py 'family' specifies
a family which doesnt have a lang 'en'.
Change-Id: Ie76528d4e43e7066229941e493a602249d3060c6
---
M tests/dry_site_tests.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/dry_site_tests.py b/tests/dry_site_tests.py
index 46b1175..042b14e 100644
--- a/tests/dry_site_tests.py
+++ b/tests/dry_site_tests.py
@@ -21,7 +21,7 @@
class TestDrySite(PywikibotTestCase):
def test_logged_in(self):
- x = DrySite('en')
+ x = DrySite('en', 'wikipedia')
x._userinfo = {'name': None, 'groups': []}
x._username = ['normal_user', 'sysop_user']
--
To view, visit https://gerrit.wikimedia.org/r/137925
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie76528d4e43e7066229941e493a602249d3060c6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: update of Vikidia's MW version
......................................................................
update of Vikidia's MW version
Change-Id: Ic7d06ca56027a8e11baed337c7b37a17d0c4012b
---
M families/vikidia_family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/families/vikidia_family.py b/families/vikidia_family.py
index 799989b..9f4c5d1 100644
--- a/families/vikidia_family.py
+++ b/families/vikidia_family.py
@@ -106,7 +106,7 @@
# Which version of MediaWiki is used? REQUIRED
def version(self, code):
# Replace with the actual version being run on your wiki
- return '1.22.2'
+ return '1.22.6'
def code2encoding(self, code):
"""Return the encoding for a specific language wiki"""
--
To view, visit https://gerrit.wikimedia.org/r/137899
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic7d06ca56027a8e11baed337c7b37a17d0c4012b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Linedwell <Linedwell(a)icloud.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Linedwell <Linedwell(a)icloud.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: update of Vikidia's MW version
......................................................................
update of Vikidia's MW version
Change-Id: I021ba207878624f051c34afe3cae2f7f39eb2f04
---
M pywikibot/families/vikidia_family.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/vikidia_family.py b/pywikibot/families/vikidia_family.py
index 189340c..28bc20a 100644
--- a/pywikibot/families/vikidia_family.py
+++ b/pywikibot/families/vikidia_family.py
@@ -40,7 +40,7 @@
# Which version of MediaWiki is used? REQUIRED
def version(self, code):
# Replace with the actual version being run on your wiki
- return '1.22.2'
+ return '1.22.6'
def code2encoding(self, code):
"""Return the encoding for a specific language wiki"""
--
To view, visit https://gerrit.wikimedia.org/r/137900
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I021ba207878624f051c34afe3cae2f7f39eb2f04
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Linedwell <Linedwell(a)icloud.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Linedwell <Linedwell(a)icloud.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: add -lonelypages option to pagegenerators
......................................................................
add -lonelypages option to pagegenerators
based on:
http://sourceforge.net/p/pywikipediabot/patches/559/
bug: 54561
Change-Id: I1e61afe05dec67573dda8f9c68fc9ade0de5bf7a
---
M pywikibot/pagegenerators.py
1 file changed, 9 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index c1a9aa7..9a2c6f5 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -129,13 +129,16 @@
Argument can be given as "-unusedfiles:n" where
n is the maximum number of articles to work on.
+-lonelypages Work on all articles that are not linked from any other article.
+ Argument can be given as "-lonelypages:n" where
+ n is the maximum number of articles to work on.
+
-unwatched Work on all articles that are not watched by anyone.
Argument can be given as "-unwatched:n" where
n is the maximum number of articles to work on.
-usercontribs Work on all articles that were edited by a certain user :
Example : -usercontribs:DumZiBoT
-
-weblink Work on all articles that contain an external link to
a given URL; may be given as "-weblink:url"
@@ -307,6 +310,11 @@
gen = UnusedFilesGenerator()
else:
gen = UnusedFilesGenerator(total=int(arg[13:]))
+ elif arg.startswith('-lonelypages'):
+ if len(arg) == 12:
+ gen = LonelyPagesPageGenerator()
+ else:
+ gen = LonelyPagesPageGenerator(total=int(arg[13:]))
elif arg.startswith('-unwatched'):
if len(arg) == 10:
gen = UnwatchedPagesPageGenerator()
--
To view, visit https://gerrit.wikimedia.org/r/137716
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I1e61afe05dec67573dda8f9c68fc9ade0de5bf7a
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: port xmlreader_tests from compat
......................................................................
port xmlreader_tests from compat
Change-Id: I8d8a51b58c1754c168e04d15b289ce61481dc221
---
A tests/data/article-pear.xml
A tests/data/article-pyrus.xml
A tests/xmlreader_tests.py
3 files changed, 268 insertions(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/data/article-pear.xml b/tests/data/article-pear.xml
new file mode 100644
index 0000000..0203a26
--- /dev/null
+++ b/tests/data/article-pear.xml
@@ -0,0 +1,109 @@
+<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en">
+ <siteinfo>
+ <sitename>Wikipedia</sitename>
+ <base>http://en.wikipedia.org/wiki/Main_Page</base>
+ <generator>MediaWiki 1.15alpha</generator>
+ <case>first-letter</case>
+ <namespaces>
+ <namespace key="-2">Media</namespace>
+ <namespace key="-1">Special</namespace>
+ <namespace key="0" />
+ <namespace key="1">Talk</namespace>
+ <namespace key="2">User</namespace>
+ <namespace key="3">User talk</namespace>
+ <namespace key="4">Wikipedia</namespace>
+ <namespace key="5">Wikipedia talk</namespace>
+ <namespace key="6">File</namespace>
+ <namespace key="7">File talk</namespace>
+ <namespace key="8">MediaWiki</namespace>
+ <namespace key="9">MediaWiki talk</namespace>
+ <namespace key="10">Template</namespace>
+ <namespace key="11">Template talk</namespace>
+ <namespace key="12">Help</namespace>
+ <namespace key="13">Help talk</namespace>
+ <namespace key="14">Category</namespace>
+ <namespace key="15">Category talk</namespace>
+ <namespace key="100">Portal</namespace>
+ <namespace key="101">Portal talk</namespace>
+ </namespaces>
+ </siteinfo>
+ <page>
+ <title>Pear</title>
+ <id>24278</id>
+ <revision>
+ <id>185185</id>
+ <timestamp>2002-02-25T15:43:11Z</timestamp>
+ <contributor>
+ <ip>Conversion script</ip>
+ </contributor>
+ <minor/>
+ <comment>Automated conversion</comment>
+ <text xml:space="preserve">Pears are [[tree]]s of the [[genus]] <em>Pyrus</em> and the edible [[fruit]] of that tree.
+The pear is an important fruit in temperate regions. Like the [[apple]], the pear fruit is a [[pome]]. There are thousands of domesticated pear varieties.
+
+There are many species of pears. The most important for fruit production are <em>Pyrus communis</em> (European pear or simply pear) and <em>Pyrus pyrifolia</em> (Asian pear or apple pear). Other species are used as rootstocks for European and Asian pears and as ornamental trees.
+
+Unlike most fruits, European pears do not ripen on the tree. They must be picked and, sometimes, subjected to cold, before they will become sweet and soft. They store well in their mature but unripe state if kept cold. Asian pears are sweet on the tree and are eaten crisp.
+
+Pears are consumed fresh, canned, and as juice. Fermented pear juice is called [[perry]].
+</text>
+ </revision>
+ <revision>
+ <id>185241</id>
+ <timestamp>2002-08-31T02:16:06Z</timestamp>
+ <contributor>
+ <username>Quercusrobur</username>
+ <id>3741</id>
+ </contributor>
+ <text xml:space="preserve">Pears are [[tree]]s of the [[genus]] <em>Pyrus</em> and the edible [[fruit]] of that tree.
+The pear is an important fruit in temperate regions. Like the [[apple]], the pear fruit is a [[pome]]. There are thousands of domesticated pear varieties.
+
+There are many species of pears. The most important for fruit production are <em>Pyrus communis</em> (European pear or simply pear) and <em>Pyrus pyrifolia</em> (Asian pear or apple pear). Other species are used as rootstocks for European and Asian pears and as ornamental trees.
+
+Unlike most fruits, European pears do not ripen on the tree. They must be picked and, sometimes, subjected to cold, before they will become sweet and soft. They store well in their mature but unripe state if kept cold. Asian pears are sweet on the tree and are eaten crisp.
+
+Pears are consumed fresh, canned, and as juice. Fermented pear juice is called [[perry]].
+
+[[propagating apples and other fruit trees]]</text>
+ </revision>
+ <revision>
+ <id>185408</id>
+ <timestamp>2002-08-31T03:27:15Z</timestamp>
+ <contributor>
+ <username>Mav</username>
+ <id>62</id>
+ </contributor>
+ <minor/>
+ <text xml:space="preserve">Pears are [[tree]]s of the [[genus]] <em>Pyrus</em> and the edible [[fruit]] of that tree.
+The pear is an important fruit in temperate regions. Like the [[apple]], the pear fruit is a [[pome]]. There are thousands of domesticated pear varieties.
+
+There are many species of pears. The most important for fruit production are <em>Pyrus communis</em> (European pear or simply pear) and <em>Pyrus pyrifolia</em> (Asian pear or apple pear). Other species are used as rootstocks for European and Asian pears and as ornamental trees.
+
+Unlike most fruits, European pears do not ripen on the tree. They must be picked and, sometimes, subjected to cold, before they will become sweet and soft. They store well in their mature but unripe state if kept cold. Asian pears are sweet on the tree and are eaten crisp.
+
+Pears are consumed fresh, canned, and as juice. Fermented pear juice is called [[perry]].
+
+[[Fruit tree propogation]]</text>
+ </revision>
+ <revision>
+ <id>188924</id>
+ <timestamp>2002-08-31T05:53:10Z</timestamp>
+ <contributor>
+ <username>PierreAbbat</username>
+ <id>1123</id>
+ </contributor>
+ <minor/>
+ <comment>sp</comment>
+ <text xml:space="preserve">Pears are [[tree]]s of the [[genus]] <em>Pyrus</em> and the edible [[fruit]] of that tree.
+The pear is an important fruit in temperate regions. Like the [[apple]], the pear fruit is a [[pome]]. There are thousands of domesticated pear varieties.
+
+There are many species of pears. The most important for fruit production are <em>Pyrus communis</em> (European pear or simply pear) and <em>Pyrus pyrifolia</em> (Asian pear or apple pear). Other species are used as rootstocks for European and Asian pears and as ornamental trees.
+
+Unlike most fruits, European pears do not ripen on the tree. They must be picked and, sometimes, subjected to cold, before they will become sweet and soft. They store well in their mature but unripe state if kept cold. Asian pears are sweet on the tree and are eaten crisp.
+
+Pears are consumed fresh, canned, and as juice. Fermented pear juice is called [[perry]].
+
+[[Fruit tree propagation]]</text>
+ </revision>
+ </page>
+</mediawiki>
diff --git a/tests/data/article-pyrus.xml b/tests/data/article-pyrus.xml
new file mode 100644
index 0000000..dfa82d3
--- /dev/null
+++ b/tests/data/article-pyrus.xml
@@ -0,0 +1,101 @@
+<mediawiki xmlns="http://www.mediawiki.org/xml/export-0.3/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mediawiki.org/xml/export-0.3/http://www.mediawiki.org/xml/export-0.3.xsd" version="0.3" xml:lang="en">
+ <siteinfo>
+ <sitename>Wikipedia</sitename>
+ <base>http://en.wikipedia.org/wiki/Main_Page</base>
+ <generator>MediaWiki 1.16alpha-wmf</generator>
+ <case>first-letter</case>
+ <namespaces>
+ <namespace key="-2">Media</namespace>
+ <namespace key="-1">Special</namespace>
+ <namespace key="0" />
+ <namespace key="1">Talk</namespace>
+ <namespace key="2">User</namespace>
+ <namespace key="3">User talk</namespace>
+ <namespace key="4">Wikipedia</namespace>
+ <namespace key="5">Wikipedia talk</namespace>
+ <namespace key="6">File</namespace>
+ <namespace key="7">File talk</namespace>
+ <namespace key="8">MediaWiki</namespace>
+ <namespace key="9">MediaWiki talk</namespace>
+ <namespace key="10">Template</namespace>
+ <namespace key="11">Template talk</namespace>
+ <namespace key="12">Help</namespace>
+ <namespace key="13">Help talk</namespace>
+ <namespace key="14">Category</namespace>
+ <namespace key="15">Category talk</namespace>
+ <namespace key="100">Portal</namespace>
+ <namespace key="101">Portal talk</namespace>
+ </namespaces>
+ </siteinfo>
+ <page>
+ <title>Pyrus</title>
+ <id>9261472</id>
+ <redirect />
+ <revision>
+ <id>104997415</id>
+ <timestamp>2007-02-02T02:39:52Z</timestamp>
+ <contributor>
+ <username>Melburnian</username>
+ <id>555187</id>
+ </contributor>
+ <comment>moved [[Pyrus]] to [[Pyrus (brand)]]: all links to ''Pyrus'' are related to the pear tree or fruit</comment>
+ <text xml:space="preserve">#REDIRECT [[Pyrus (brand)]]</text>
+ </revision>
+ <revision>
+ <id>104997738</id>
+ <timestamp>2007-02-02T02:41:24Z</timestamp>
+ <contributor>
+ <username>Melburnian</username>
+ <id>555187</id>
+ </contributor>
+ <comment>all links to ''Pyrus'' are related to the pear tree or fruit</comment>
+ <text xml:space="preserve">#REDIRECT [[Pear]]</text>
+ </revision>
+ <revision>
+ <id>189729426</id>
+ <timestamp>2008-02-07T14:06:10Z</timestamp>
+ <contributor>
+ <username>Jkokemueller</username>
+ <id>6303952</id>
+ </contributor>
+ <comment>Added disambiguation</comment>
+ <text xml:space="preserve">'''Pyrus''' may refer to:
+
+* [[Pear]], trees of the genus ''Pyrus'' and the fruit of that tree, edible in some species
+* [[Main//Pyrus DMS]], a [[Document Management System]]</text>
+ </revision>
+ <revision>
+ <id>190346463</id>
+ <timestamp>2008-02-10T07:21:12Z</timestamp>
+ <contributor>
+ <username>IceCreamAntisocial</username>
+ <id>346507</id>
+ </contributor>
+ <minor/>
+ <comment>rv</comment>
+ <text xml:space="preserve">#REDIRECT [[Pear]]</text>
+ </revision>
+ <revision>
+ <id>238138507</id>
+ <timestamp>2008-09-13T12:57:33Z</timestamp>
+ <contributor>
+ <username>Cottonapple4</username>
+ <id>7707615</id>
+ </contributor>
+ <comment>[[WP:AES|←]] Redirected page to [[Pear]]</comment>
+ <text xml:space="preserve">#REDIRECT [[Pear]]
+[[Category:Maloideae]]</text>
+ </revision>
+ <revision>
+ <id>238392911</id>
+ <timestamp>2008-09-14T17:08:56Z</timestamp>
+ <contributor>
+ <username>Rkitko</username>
+ <id>536375</id>
+ </contributor>
+ <minor/>
+ <comment>Reverted edits by [[Special:Contributions/Cottonapple4|Cottonapple4]] ([[User talk:Cottonapple4|talk]]) to last version by IceCreamAntisocial</comment>
+ <text xml:space="preserve">#REDIRECT [[Pear]]</text>
+ </revision>
+ </page>
+</mediawiki>
diff --git a/tests/xmlreader_tests.py b/tests/xmlreader_tests.py
new file mode 100644
index 0000000..1c26591
--- /dev/null
+++ b/tests/xmlreader_tests.py
@@ -0,0 +1,58 @@
+# -*- coding: utf-8 -*-
+"""
+Tests for xmlreader module.
+"""
+#
+# (C) Pywikibot team, 2014
+#
+# Distributed under the terms of the MIT license.
+#
+__version__ = '$Id$'
+
+
+import os.path
+from pywikibot import xmlreader
+from tests.utils import unittest
+
+
+class XmlReaderTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.path = os.path.dirname(os.path.abspath(__file__))
+
+ def test_XmlDumpAllRevs(self):
+ pages = [r for r in
+ xmlreader.XmlDump(os.path.join(self.path, 'data',
+ "article-pear.xml"),
+ allrevisions=True).parse()]
+ self.assertEquals(4, len(pages))
+ self.assertEquals(u"Automated conversion", pages[0].comment)
+ self.assertEquals(u"Pear", pages[0].title)
+ self.assertEquals(u"24278", pages[0].id)
+ self.assertTrue(pages[0].text.startswith('Pears are [[tree]]s of'))
+ self.assertEquals(u"Quercusrobur", pages[1].username)
+ self.assertEquals(u"Pear", pages[0].title)
+
+ def test_XmlDumpFirstRev(self):
+ pages = [r for r in
+ xmlreader.XmlDump(os.path.join(self.path, 'data',
+ "article-pear.xml")).parse()]
+ self.assertEquals(1, len(pages))
+ self.assertEquals(u"Automated conversion", pages[0].comment)
+ self.assertEquals(u"Pear", pages[0].title)
+ self.assertEquals(u"24278", pages[0].id)
+ self.assertTrue(pages[0].text.startswith('Pears are [[tree]]s of'))
+ self.assertTrue(not pages[0].isredirect)
+
+ def test_XmlDumpRedirect(self):
+ pages = [r for r in
+ xmlreader.XmlDump(os.path.join(self.path, 'data',
+ "article-pyrus.xml")).parse()]
+ self.assertTrue(pages[0].isredirect)
+
+
+if __name__ == '__main__':
+ try:
+ unittest.main()
+ except SystemExit:
+ pass
--
To view, visit https://gerrit.wikimedia.org/r/137677
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8d8a51b58c1754c168e04d15b289ce61481dc221
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>