jenkins-bot has submitted this change and it was merged.
Change subject: [flickrripper] Fallback to photo_id for filename when no title is set
......................................................................
[flickrripper] Fallback to photo_id for filename when no title is set
Otherwise filename is invalid (leading space) and also duplicate.
Tested on Commons, all is well.
Change-Id: I5cc2d9fce0a7768527b6e14b88880e3c7630be8a
---
M flickrripper.py
1 file changed, 3 insertions(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/flickrripper.py b/flickrripper.py
index 24d676e..5e7297c 100644
--- a/flickrripper.py
+++ b/flickrripper.py
@@ -140,7 +140,7 @@
return rawDescription.decode('utf-8')
-def getFilename(photoInfo=None, site=None, project=u'Flickr'):
+def getFilename(photoInfo=None, site=None, project=u'Flickr', photoId=None):
""" Build a good filename for the upload based on the username and the
title. Prevents naming collisions.
@@ -166,8 +166,7 @@
description = description[:items]
title = cleanUpTitle(description)
else:
- title = u''
- # Should probably have the id of the photo as last resort.
+ title = photoId
if pywikibot.Page(site, u'File:%s - %s - %s.jpg'
% (title, project, username)).exists():
@@ -256,7 +255,7 @@
if duplicates:
pywikibot.output(u'Found duplicate image at %s' % duplicates.pop())
else:
- filename = getFilename(photoInfo)
+ filename = getFilename(photoInfo, photoId=photo_id)
flinfoDescription = getFlinfoDescription(photo_id)
photoDescription = buildDescription(flinfoDescription,
flickrreview, reviewer,
--
To view, visit https://gerrit.wikimedia.org/r/90097
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I5cc2d9fce0a7768527b6e14b88880e3c7630be8a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Nemo bis <federicoleva(a)tiscali.it>
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: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Nemo bis <federicoleva(a)tiscali.it>
Gerrit-Reviewer: Platonides <platonides(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Show page generators parameters in module documentation
......................................................................
Show page generators parameters in module documentation
Change-Id: I8e0f72a35d6923c54d45d31b179f105704af9a4b
---
M pywikibot/pagegenerators.py
1 file changed, 5 insertions(+), 0 deletions(-)
Approvals:
Xqt: Looks good to me, approved
Mineo: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/pagegenerators.py b/pywikibot/pagegenerators.py
index d749dbc..fbc27c2 100644
--- a/pywikibot/pagegenerators.py
+++ b/pywikibot/pagegenerators.py
@@ -169,6 +169,11 @@
# if a bot uses GeneratorFactory, the module should include the line
# docuReplacements = {'¶ms;': pywikibot.pagegenerators.parameterHelp}
# and include the marker ¶ms; in the module's docstring
+#
+# We manually include it so the parameters show up in the auto-generated
+# module documentation:
+
+__doc__ = __doc__.replace("¶ms;", parameterHelp)
class GeneratorFactory(object):
--
To view, visit https://gerrit.wikimedia.org/r/90728
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8e0f72a35d6923c54d45d31b179f105704af9a4b
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mineo <themineo(a)gmail.com>
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 line from docstring (-api flag not used in core).
......................................................................
Remove obsolete line from docstring (-api flag not used in core).
Change-Id: I3b802c50ac08a9e229f306572f0e3e74f51dc475
---
M scripts/redirect.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Legoktm: Looks good to me, approved
Xqt: Verified; Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/redirect.py b/scripts/redirect.py
index 57778ac..233cad9 100755
--- a/scripts/redirect.py
+++ b/scripts/redirect.py
@@ -13,7 +13,7 @@
double Fix redirects which point to other redirects
broken Delete redirects where targets don\'t exist. Requires adminship.
-both Both of the above. Permitted only with -api. Implies -api.
+both Both of the above.
and arguments can be:
--
To view, visit https://gerrit.wikimedia.org/r/90680
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I3b802c50ac08a9e229f306572f0e3e74f51dc475
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Nemo bis <federicoleva(a)tiscali.it>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Catlib: Removed duplicated code and refactored
......................................................................
Catlib: Removed duplicated code and refactored
Change-Id: Ie90b6432f18e0de768c23db9f4f7e207196235ab
---
M catlib.py
1 file changed, 40 insertions(+), 56 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/catlib.py b/catlib.py
index 6e17363..c2ca83f 100644
--- a/catlib.py
+++ b/catlib.py
@@ -623,81 +623,62 @@
def change_category(article, oldCat, newCat, comment=None, sortKey=None,
inPlace=False):
- """Given an article which is in category oldCat, moves it to
- category newCat. Moves subcategories of oldCat as well.
- oldCat and newCat should be Category objects.
- If newCat is None, the category will be removed.
+ """
+ Remove page from oldCat and add it to newCat.
+
+ @param oldCat and newCat: should be Category objects.
+ If newCat is None, the category will be removed.
+
+ @param comment: string to use as an edit summary
+
+ @param sortKey: sortKey to use for the added category.
+ Unused if newCat is None, or if inPlace=True
+
+ @param inPlace: if True, change categories in place rather than
+ rearranging them.
"""
- cats = article.categories(get_redirect=True)
+ #get list of Category objects the article is in and remove possible duplicates
+ cats = []
+ for cat in article.categories(get_redirect=True):
+ if cat not in cats:
+ cats.append(cat)
+
site = article.site()
- changesMade = False
+
+ if not sortKey:
+ sortKey = oldCat.sortKey
if not article.canBeEdited():
pywikibot.output("Can't edit %s, skipping it..."
% article.title(asLink=True))
return
+
+ if oldCat not in cats:
+ pywikibot.error(u'%s is not in category %s!'
+ % (article.title(asLink=True), oldCat.title()))
+ return
+
if inPlace or article.namespace() == 10:
oldtext = article.get(get_redirect=True)
newtext = pywikibot.replaceCategoryInPlace(oldtext, oldCat, newCat)
- if newtext == oldtext:
- pywikibot.output(
- u'No changes in made in page %s.' % article.title(asLink=True))
- return
- try:
- article.put(newtext, comment)
- return True
- except pywikibot.EditConflict:
- pywikibot.output(u'Skipping %s because of edit conflict'
- % article.title(asLink=True))
- except pywikibot.LockedPage:
- pywikibot.output(u'Skipping locked page %s'
- % article.title(asLink=True))
- except pywikibot.SpamfilterError, error:
- pywikibot.output(u'Changing page %s blocked by spam filter (URL=%s)'
- % (article.title(asLink=True), error.url))
- except pywikibot.NoUsername:
- pywikibot.output(u'Page %s not saved; sysop privileges required.'
- % article.title(asLink=True))
- except pywikibot.PageNotSaved, error:
- pywikibot.output(u'Saving page %s failed: %s'
- % (article.title(asLink=True), error.message))
- return
-
- # This loop will replace all occurrences of the category to be changed,
- # and remove duplicates.
- newCatList = []
- newCatSet = set()
- for i in range(len(cats)):
- cat = cats[i]
- if cat == oldCat:
- changesMade = True
- if not sortKey:
- sortKey = cat.sortKey
- if newCat:
- if newCat.title() not in newCatSet:
- newCategory = Category(site, newCat.title(),
- sortKey=sortKey)
- newCatSet.add(newCat.title())
- newCatList.append(newCategory)
- elif cat.title() not in newCatSet:
- newCatSet.add(cat.title())
- newCatList.append(cat)
-
- if not changesMade:
- pywikibot.error(u'%s is not in category %s!'
- % (article.title(asLink=True), oldCat.title()))
else:
- text = article.get(get_redirect=True)
+ if newCat:
+ cats[cats.index(oldCat)] = Category(site, newCat.title(), sortKey=sortKey)
+ else:
+ cats.pop(cats.index(oldCat))
+ oldtext = article.get(get_redirect=True)
try:
- text = pywikibot.replaceCategoryLinks(text, newCatList)
+ newtext = pywikibot.replaceCategoryLinks(oldtext, cats)
except ValueError:
# Make sure that the only way replaceCategoryLinks() can return
# a ValueError is in the case of interwiki links to self.
pywikibot.output(u'Skipping %s because of interwiki link to self'
% article)
+
+ if oldtext != newtext:
try:
- article.put(text, comment)
+ article.put(newtext, comment)
except pywikibot.EditConflict:
pywikibot.output(u'Skipping %s because of edit conflict'
% article.title())
@@ -707,6 +688,9 @@
except pywikibot.LockedPage:
pywikibot.output(u'Skipping %s because page is locked'
% article.title())
+ except pywikibot.NoUsername:
+ pywikibot.output(u'Page %s not saved; sysop privileges required.'
+ % article.title(asLink=True))
except pywikibot.PageNotSaved, error:
pywikibot.output(u"Saving page %s failed: %s"
% (article.title(asLink=True), error.message))
--
To view, visit https://gerrit.wikimedia.org/r/90662
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie90b6432f18e0de768c23db9f4f7e207196235ab
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/compat
Gerrit-Branch: master
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change and it was merged.
Change subject: win32_unicode: make sure argv always has a first element
......................................................................
win32_unicode: make sure argv always has a first element
If Python is started without script as argument, argv is [''], and thus
argvu should be [u''] and not [].
Change-Id: I380b85bfe11615289ab47a483b5d1746a5137a76
---
M pywikibot/userinterfaces/win32_unicode.py
1 file changed, 3 insertions(+), 0 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/userinterfaces/win32_unicode.py b/pywikibot/userinterfaces/win32_unicode.py
index 3646dc0..b06025a 100755
--- a/pywikibot/userinterfaces/win32_unicode.py
+++ b/pywikibot/userinterfaces/win32_unicode.py
@@ -256,3 +256,6 @@
if arg == u'-c':
argv[0] = u'-c'
break
+
+ if argv == []:
+ argv = [u'']
--
To view, visit https://gerrit.wikimedia.org/r/86385
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I380b85bfe11615289ab47a483b5d1746a5137a76
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Xqt has submitted this change and it was merged.
Change subject: Improve Windows Terminal UI tests
......................................................................
Improve Windows Terminal UI tests
- Refactored generic terminal testcase out of the Windows I/O testcase
- Getstdinout is now triggered by a sentinel being overwritten by the
copy operation
- Wait for the window to be ready before sending keys
- Add ui_tests.bat to run ui_tests correctly on Windows
Change-Id: Id132afbd51999a7db3974c0fddd5016c35c7a335
---
A tests/ui_tests.bat
M tests/ui_tests.py
2 files changed, 61 insertions(+), 12 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/tests/ui_tests.bat b/tests/ui_tests.bat
new file mode 100644
index 0000000..c497d6e
--- /dev/null
+++ b/tests/ui_tests.bat
@@ -0,0 +1,4 @@
+@echo off
+set PYTHONPATH=%~dp0..;%~dp0../externals
+set PYWIKIBOT2_DIR=%~dp0..
+"%~dp0ui_tests.py"
diff --git a/tests/ui_tests.py b/tests/ui_tests.py
index d4ba066..4b1634c 100644
--- a/tests/ui_tests.py
+++ b/tests/ui_tests.py
@@ -7,6 +7,26 @@
#
# Distributed under the terms of the MIT license.
#
+
+# NOTE FOR RUNNING WINDOWS UI TESTS
+#
+# Windows UI tests have to be run using the tests\ui_tests.bat helper script.
+# This will set PYTHONPATH and PYWIKIBOT2_DIR, and then run the tests. Do not
+# touch mouse or keyboard while the tests are running, as this might disturb the
+# interaction tests.
+#
+# The Windows tests were developed on a Dutch Windows 7 OS. You might need to adapt the
+# helper functions in TestWindowsTerminalUnicode for other versions.
+#
+# For the Windows-based tests, you need the following packages installed:
+# - pywin32, for clipboard access, which can be downloaded here:
+# http://sourceforge.net/projects/pywin32/files/pywin32/Build%20218/
+# make sure to download the package for the correct python version!
+#
+# - pywinauto, to send keys to the terminal, which can be installed using:
+# easy_install --upgrade https://pywinauto.googlecode.com/files/pywinauto-0.4.2.zip
+#
+#
__version__ = '$Id$'
import unittest
@@ -15,6 +35,7 @@
import logging
import os
import sys
+import time
if os.name == "nt":
from multiprocessing.managers import BaseManager
@@ -328,19 +349,15 @@
self.assertEqual(newstderr.getvalue(), "abcd \x1b[33;1mA\x1b[0m\x1b[33;1mB\x1b[0m\x1b[33;1mG\x1b[0m\x1b[33;1mD\x1b[0m \x1b[33;1ma\x1b[0m\x1b[33;1mb\x1b[0m\x1b[33;1mg\x1b[0m\x1b[33;1md\x1b[0m \x1b[33;1ma\x1b[0m\x1b[33;1mi\x1b[0m\x1b[33;1mu\x1b[0m\x1b[33;1me\x1b[0m\x1b[33;1mo\x1b[0m\n\x1b[0m") # noqa
@unittest.skipUnless(os.name == "nt", "requires Windows console")
- class TestWindowsTerminalUnicode(UITestCase):
+ class WindowsTerminalTestCase(UITestCase):
@classmethod
- def setUpClass(cls):
- import inspect
+ def setUpProcess(cls, command):
import pywinauto
import subprocess
si = subprocess.STARTUPINFO()
si.dwFlags = subprocess.STARTF_USESTDHANDLES
- fn = inspect.getfile(inspect.currentframe())
- cls._process = subprocess.Popen(["python", "pwb.py", fn, "--run-as-slave-interpreter"],
+ cls._process = subprocess.Popen(command,
creationflags=subprocess.CREATE_NEW_CONSOLE)
- _manager.connect()
- cls.pywikibot = _manager.pywikibot()
cls._app = pywinauto.application.Application()
cls._app.connect_(process=cls._process.pid)
@@ -349,15 +366,29 @@
cls._app.window_().TypeKeys("% {UP}{ENTER}^L{HOME}L{ENTER}", with_spaces=True)
@classmethod
- def tearDownClass(cls):
- del cls.pywikibot
+ def tearDownProcess(cls):
cls._process.kill()
+ def setUp(self):
+ super(WindowsTerminalTestCase, self).setUp()
+ self.setclip(u'')
+
+ def waitForWindow(self):
+ while not self._app.window_().IsEnabled():
+ time.sleep(0.01)
+
def getstdouterr(self):
+ sentinel = u'~~~~SENTINEL~~~~cedcfc9f-7eed-44e2-a176-d8c73136c185'
# select all and copy to clipboard
self._app.window_().SetFocus()
+ self.waitForWindow()
self._app.window_().TypeKeys('% {UP}{UP}{UP}{RIGHT}{DOWN}{DOWN}{DOWN}{ENTER}{ENTER}', with_spaces=True)
- return self.getclip()
+
+ while True:
+ data = self.getclip()
+ if data != sentinel:
+ return data
+ time.sleep(0.01)
def setclip(self, text):
win32clipboard.OpenClipboard()
@@ -375,8 +406,23 @@
def sendstdin(self, text):
self.setclip(text.replace(u"\n", u"\r\n"))
self._app.window_().SetFocus()
+ self.waitForWindow()
self._app.window_().TypeKeys('% {UP}{UP}{UP}{RIGHT}{DOWN}{DOWN}{ENTER}', with_spaces=True)
- self.setclip(u'')
+
+ class TestWindowsTerminalUnicode(WindowsTerminalTestCase):
+ @classmethod
+ def setUpClass(cls):
+ import inspect
+ fn = inspect.getfile(inspect.currentframe())
+ cls.setUpProcess(["python", "pwb.py", fn, "--run-as-slave-interpreter"])
+
+ _manager.connect()
+ cls.pywikibot = _manager.pywikibot()
+
+ @classmethod
+ def tearDownClass(cls):
+ del cls.pywikibot
+ cls.tearDownProcess()
def setUp(self):
super(TestWindowsTerminalUnicode, self).setUp()
@@ -388,7 +434,6 @@
self.pywikibot.set_ui('encoding', 'utf-8')
self.pywikibot.cls()
- self.setclip(u'')
def testOutputUnicodeText_no_transliterate(self):
self.pywikibot.output(u"Заглавная_страница")
--
To view, visit https://gerrit.wikimedia.org/r/86384
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id132afbd51999a7db3974c0fddd5016c35c7a335
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
jenkins-bot has submitted this change and it was merged.
Change subject: Find correct line feed in text, fix for right placement of header with noreferences.py (Bug 55409) (update from compat gerrit 88121)
......................................................................
Find correct line feed in text,
fix for right placement of header with noreferences.py (Bug 55409)
(update from compat gerrit 88121)
Change-Id: I9de67bfb3713106c30d26af9c6faf30c0156c4df
---
M scripts/noreferences.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Merlijn van Deen: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py
index 8c8e0dd..cb857e0 100755
--- a/scripts/noreferences.py
+++ b/scripts/noreferences.py
@@ -480,7 +480,7 @@
"""
# Is there an existing section where we can add the references tag?
for section in pywikibot.translate(self.site, referencesSections):
- sectionR = re.compile(r'\r\n=+ *%s *=+ *\r\n' % section)
+ sectionR = re.compile(r'\r?\n=+ *%s *=+ *\r?\n' % section)
index = 0
while index < len(oldText):
match = sectionR.search(oldText, index)
@@ -502,7 +502,7 @@
# Create a new section for the references tag
for section in pywikibot.translate(self.site, placeBeforeSections):
# Find out where to place the new section
- sectionR = re.compile(r'\r\n(?P<ident>=+) *%s *(?P=ident) *\r\n'
+ sectionR = re.compile(r'\r?\n(?P<ident>=+) *%s *(?P=ident) *\r?\n'
% section)
index = 0
while index < len(oldText):
@@ -541,9 +541,9 @@
### {{commons}} or {{commonscat}} are part of Weblinks section
### * {{template}} is mostly part of a section
### so templatePattern must be fixed
- templatePattern = r'\r\n{{((?!}}).)+?}}\s*'
+ templatePattern = r'\r?\n{{((?!}}).)+?}}\s*'
commentPattern = r'<!--((?!-->).)*?-->\s*'
- metadataR = re.compile(r'(\r\n)?(%s|%s|%s|%s)$'
+ metadataR = re.compile(r'(\r?\n)?(%s|%s|%s|%s)$'
% (categoryPattern, interwikiPattern,
templatePattern, commentPattern), re.DOTALL)
tmpText = oldText
--
To view, visit https://gerrit.wikimedia.org/r/88122
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9de67bfb3713106c30d26af9c6faf30c0156c4df
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
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