jenkins-bot has submitted this change and it was merged.
Change subject: Misspellings
......................................................................
Misspellings
Change-Id: Iae6bc175df0f5ba3d193c5e7ad3b5168f31c77d1
---
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/comms/http.py
M pywikibot/data/api.py
M pywikibot/exceptions.py
M pywikibot/i18n.py
M pywikibot/login.py
M pywikibot/page.py
M pywikibot/site.py
M pywikibot/textlib.py
M pywikibot/userinterfaces/terminal_interface_base.py
11 files changed, 72 insertions(+), 66 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ladsgroup: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 83093f5..b8cc7c5 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -36,7 +36,7 @@
class Timestamp(datetime.datetime):
- """Class for handling Mediawiki timestamps.
+ """Class for handling MediaWiki timestamps.
This inherits from datetime.datetime, so it can use all of the methods
and operations of a datetime object. To ensure that the results of any
@@ -44,7 +44,7 @@
objects (and datetime.timedeltas) in any operation.
Use Timestamp.fromISOformat() and Timestamp.fromtimestampformat() to
- create Timestamp objects from Mediawiki string formats.
+ create Timestamp objects from MediaWiki string formats.
Use Site.getcurrenttime() for the current time; this is more reliable
than using Timestamp.utcnow().
@@ -106,7 +106,7 @@
"""
@param lat: Latitude
@type lat: float
- @param lon: Longitute
+ @param lon: Longitude
@type lon: float
@param alt: Altitute? TODO FIXME
@param precision: precision
@@ -119,7 +119,7 @@
@type name: str
@param dim: Dimension (in meters)
@type dim: int
- @param entity: The url entity of a Wikibase item
+ @param entity: The URL entity of a Wikibase item
@type entity: str
"""
self.lat = lat
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index a98eba8..074fe7d 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -54,6 +54,8 @@
def doRollover(self):
"""
+ Modified naming system for logging files.
+
Overwrites the default Rollover renaming by inserting the count number
between file name root and extension. If backupCount is >= 1, the system
will successively create new files with the same pathname as the base
@@ -67,7 +69,7 @@
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
- starts from the lowest availlable (unused) number.
+ starts from the lowest available (unused) number.
"""
if self.stream:
@@ -101,7 +103,7 @@
self.stream = self._open()
def format(self, record):
- """Strip trailing newlines before outputting text to file"""
+ """Strip trailing newlines before outputting text to file."""
text = logging.handlers.RotatingFileHandler.format(self, record)
return text.rstrip("\r\n")
@@ -117,7 +119,8 @@
"""
def formatException(self, ei):
"""
- Make sure that the exception trace is converted to unicode:
+ Convert exception trace to unicode if necessary.
+
* our pywikibot.Error traces are encoded in our
console encoding, which is needed for plainly printing them.
* but when it comes to logging using logging.exception,
@@ -244,8 +247,9 @@
def writelogheader():
"""
- Save additional version, system and status info to the logfile in use,
- so that the user can look it up later to track errors or report bugs.
+ Save additional version, system and status info to the log file in use.
+
+ This may help the user to track errors or report bugs.
"""
# if site not available it's too early to print a header (work-a-round)
try:
@@ -340,7 +344,7 @@
**kwargs):
"""Format output and send to the logging module.
- Backend function used by all the user-output convenience functions.
+ Helper function used by all the user-output convenience functions.
"""
if _logger:
@@ -385,7 +389,7 @@
If decoder is None, text should be a unicode string. Otherwise it
should be encoded in the given encoding.
- If newline is True, a linebreak will be added after printing the text.
+ If newline is True, a line feed will be added after printing the text.
If toStdout is True, the text will be sent to standard output,
so that it can be piped to another process. All other text will
@@ -534,7 +538,7 @@
def handleArgs(*args):
"""Handle standard command line arguments, return the rest as a list.
- Takes the commandline arguments as Unicode strings, processes all
+ Takes the command line arguments as Unicode strings, processes all
global parameters such as -lang or -log. Returns a list of all arguments
that are not global. This makes sure that global arguments are applied
first, regardless of the order in which the arguments were given.
@@ -702,13 +706,13 @@
-help Show this help text.
--log Enable the logfile, using the default filename
+-log Enable the log file, using the default filename
'%s-bot.log'
Logs will be stored in the logs subdirectory.
--log:xyz Enable the logfile, using 'xyz' as the filename.
+-log:xyz Enable the log file, using 'xyz' as the filename.
--nolog Disable the logfile (if it is enabled by default).
+-nolog Disable the log file (if it is enabled by default).
-maxlag Sets a new maxlag parameter to a number of seconds. Defer bot
edits during periods of database server lag. Default is set by
@@ -718,7 +722,7 @@
-pt:n saving pages.
-put_throttle:n
--debug:item Enable the logfile and include extensive debugging data
+-debug:item Enable the log file and include extensive debugging data
-debug for component "item" (for all components if the second form
is used).
@@ -844,8 +848,9 @@
def cacheSources(self):
"""
- Fetches the sources from the onwiki list
- and stores it internally
+ Fetch the sources from the list on Wikidata.
+
+ It is stored internally and reused by getSource()
"""
page = pywikibot.Page(self.repo, u'List of wikis/python', ns=4)
self.source_values = json.loads(page.get())
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 4f69291..cae3ab0 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -7,8 +7,8 @@
This module is responsible for
- Setting up a connection pool
- Providing a (blocking) interface for HTTP requests
- - Translate site objects with query strings into urls
- - Urlencoding all data
+ - Translate site objects with query strings into URLs
+ - URL-encoding all data
- Basic HTTP error handling
"""
@@ -127,12 +127,12 @@
L{httplib2.Http.request}, but the uri is relative
If the site argument is None the uri has to be absolute and is
- taken. In this case ssl is ignored. Used for requests to non wiki
+ taken. In this case SSL is ignored. Used for requests to non wiki
pages.
@param site: The Site to connect to
@param uri: the URI to retrieve (relative to the site's scriptpath)
- @param ssl: Use https connection
+ @param ssl: Use HTTPS connection
@return: The received data (a unicode string).
"""
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index bb5c1cb..2e693c3 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -934,7 +934,7 @@
Parameters are all ignored.
- Returns cookie data if succesful, None otherwise.
+ Returns cookie data if successful, None otherwise.
"""
if hasattr(self, '_waituntil'):
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index b7a4fd5..7f9a06d 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -141,7 +141,7 @@
class Server504Error(Error):
- """Server timed out with http 504 code"""
+ """Server timed out with HTTP 504 code"""
class BadTitle(Error):
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index dc6b697..2908481 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -36,7 +36,7 @@
one with a translation, with 'en' and '_default' as a last resort.
For example, if for language 'xx', you want the preference of languages
- to be: xx > fr > ru > en, you let altlang return ['fr', 'ru'].
+ to be: xx > fr > ru > en, you let this method return ['fr', 'ru'].
This code is used by other translating methods below.
@@ -285,7 +285,7 @@
Given a language code and a dictionary, returns the dictionary's value for
key 'code' if this key exists; otherwise tries to return a value for an
- alternative language that is most applicable to use on the Wikipedia in
+ alternative language that is most applicable to use on the wiki in
language 'code' except fallback is False.
The language itself is always checked first, then languages that
@@ -397,14 +397,14 @@
# Maybe this function should be merged with twtranslate
def twntranslate(code, twtitle, parameters=None):
""" First implementation of plural support for translations based on the
- TW title twtitle, which corresponds to a page on TW.
+ TranslateWiki title twtitle, which corresponds to a page on TranslateWiki.
@param code The language code
@param twtitle The TranslateWiki string title, in <package>-<key> format
@param parameters For passing (plural) parameters.
- Support is implemented like in MediaWiki extension. If the tw message
- contains a plural tag inside which looks like
+ Support is implemented like in MediaWiki extension. If the TranslateWiki
+ message contains a plural tag inside which looks like
{{PLURAL:<number>|<variant1>|<variant2>[|<variantn>]}}
it takes that variant calculated by the plural_rules depending on the number
value. Multiple plurals are allowed.
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 9035b8a..aa23d9d 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -100,7 +100,7 @@
remember Remember login (default: True)
captchaId A dictionary containing the captcha id and answer, if any
- Returns cookie data if succesful, None otherwise.
+ Returns cookie data if successful, None otherwise.
"""
# NOT IMPLEMENTED - see data/api.py for implementation
@@ -134,7 +134,7 @@
to set a default password for an username. The last matching entry will
be used, so default usernames should occur above specific usernames.
- If the username or password contain non-ascii characters, they
+ If the username or password contain non-ASCII characters, they
should be stored using the utf-8 encoding.
Example:
diff --git a/pywikibot/page.py b/pywikibot/page.py
index c45d5b4..778691e 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -669,7 +669,7 @@
If get_Index is True then also load the templates for index articles
which are given on en-wiki
- Template:Disambig is always assumed to be default, and will be
+ 'Template:Disambig' is always assumed to be default, and will be
appended regardless of its existence.
@return: bool
@@ -1109,7 +1109,7 @@
continue
def langlinks(self, include_obsolete=False):
- """Return a list of all interlanguage Links on this page.
+ """Return a list of all inter-language Links on this page.
@param include_obsolete: if true, return even Link objects whose site
is obsolete
@@ -1130,7 +1130,7 @@
return filter(lambda i: not i.site.obsolete, self._langlinks)
def iterlanglinks(self, step=None, total=None, include_obsolete=False):
- """Iterate all interlanguage links on this page.
+ """Iterate all inter-language links on this page.
@param step: limit each API call to this number of pages
@param total: iterate no more than this number of pages in total
@@ -1295,7 +1295,7 @@
def coordinates(self, primary_only=False):
"""Return a list of Coordinate objects for points on the page.
- Uses [[mw:Extension:GeoData]]
+ Uses the MediaWiki extension GeoData.
@param primary_only: Only return the coordinate indicated to be primary
@return: A list of Coordinate objects
@@ -3100,7 +3100,7 @@
def newClaim(self, *args, **kwargs):
"""
- Convenicence function to create a new claim object for this property.
+ Helper function to create a new claim object for this property.
@return: Claim
"""
@@ -3142,7 +3142,7 @@
@type site: pywikibot.site.DataSite
@param pid: property id, with "P" prefix
@param snak: snak identifier for claim
- @param hash: hash identifer for references
+ @param hash: hash identifier for references
@param isReference: whether specified claim is a reference
@param isQualifier: whether specified claim is a qualifier
"""
@@ -3228,7 +3228,7 @@
@staticmethod
def qualifierFromJSON(site, data):
"""
- Create a Claim for a qualifer from JSON.
+ Create a Claim for a qualifier from JSON.
Qualifier objects are represented a bit
differently like references, but I'm not
@@ -3261,7 +3261,7 @@
@param value: The new target value.
@type value: object
- @param snaktype: The new snaktype.
+ @param snaktype: The new snak type.
@type value: str ('value', 'somevalue', or 'novalue')
"""
if value:
@@ -3284,14 +3284,14 @@
def getSnakType(self):
"""
- Return the "snaktype".
+ Return the type of snak.
@return: str ('value', 'somevalue' or 'novalue')
"""
return self.snaktype
def setSnakType(self, value):
- """Set the "snaktype".
+ """Set the type of snak.
@param value: Type of snak
@type value: str ('value', 'somevalue', or 'novalue')
@@ -3316,7 +3316,7 @@
def changeSnakType(self, value=None, **kwargs):
"""
- Save the new snakvalue.
+ Save the new snak value.
TODO: Is this function really needed?
"""
@@ -3547,7 +3547,7 @@
with multiple interwiki prefixes (such as "wikt:fr:Parlais") need
to be re-parsed on the first linked wiki to get the actual site.
- @return: tuple of (familyname, languagecode) for the linked site.
+ @return: tuple of (family-name, language-code) for the linked site.
"""
t = self._text
@@ -3966,7 +3966,7 @@
def UnicodeToAsciiHtml(s):
- """Convert unicode to a bytestring using HTML entities."""
+ """Convert unicode to a str using HTML entities."""
html = []
for c in s:
cord = ord(c)
@@ -3983,7 +3983,7 @@
Attempt to encode the
string into the desired format; if that doesn't work, encode the unicode
- into html &#; entities. If it does work, return it unchanged.
+ into HTML &#; entities. If it does work, return it unchanged.
@param x: String to update
@type x: unicode
@@ -4000,7 +4000,7 @@
def url2unicode(title, site, site2=None):
- """Convert url-encoded text to unicode using site's encoding.
+ """Convert URL-encoded text to unicode using site's encoding.
If site2 is provided, try its encodings as well. Uses the first encoding
that doesn't cause an error.
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 84f06b9..2121d66 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -584,7 +584,7 @@
""" Decorator to require a certain MediaWiki version number.
@param number: the mw version number required
- @return: a decorator to make sure the requirement is statisfied when
+ @return: a decorator to make sure the requirement is satisfied when
the decorated function is called.
"""
def decorator(fn):
@@ -3465,7 +3465,7 @@
Newpages again. If there is no new page, it blocks until there is
one, sleeping between subsequent fetches of Newpages.
- The objects yielded are dependent on paramater returndict.
+ The objects yielded are dependent on parameter returndict.
When true, it yields a tuple composed of a Page object and a dict of
attributes.
When false, it yields a tuple composed of the Page object,
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 47b9f7a..64dbf3c 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -50,9 +50,9 @@
"""
Return text with 'old' replaced by 'new', ignoring specified types of text.
- Skips occurences of 'old' within exceptions; e.g., within nowiki tags or
+ Skips occurrences of 'old' within exceptions; e.g., within nowiki tags or
HTML comments. If caseInsensitive is true, then use case insensitive
- regex matching. If allowoverlap is true, overlapping occurences are all
+ regex matching. If allowoverlap is true, overlapping occurrences are all
replaced (watch out when using this, it might lead to infinite loops!).
Parameters:
@@ -379,9 +379,9 @@
# Functions dealing with interwiki language links
# -----------------------------------------------
# Note - MediaWiki supports several kinds of interwiki links; two kinds are
-# interlanguage links. We deal here with those kinds only.
-# A family has by definition only one kind of interlanguage links:
-# 1 - interlanguage links inside the own family.
+# inter-language links. We deal here with those kinds only.
+# A family has by definition only one kind of inter-language links:
+# 1 - inter-language links inside the own family.
# They go to a corresponding page in another language in the same
# family, such as from 'en.wikipedia' to 'pt.wikipedia', or from
# 'es.wiktionary' to 'arz.wiktionary'.
@@ -392,7 +392,7 @@
# 'commons' to 'zh.wikipedia, or from 'incubator' to 'en.wikipedia'.
# Families having those have one member only, and do not have
# language-specific sites. The name of the target family of their
-# interlanguage links is kept in their interwiki_forward attribute.
+# inter-language links is kept in their interwiki_forward attribute.
# These functions only deal with links of these two kinds only. They
# do not find or change links of other kinds, nor any that are formatted
# as in-line interwiki links (e.g., "[[:es:Articulo]]".
@@ -400,9 +400,10 @@
def getLanguageLinks(text, insite=None, pageLink="[[]]",
template_subpage=False):
"""
- Return a dict of interlanguage links found in text.
+ Return a dict of inter-language links found in text.
- Dict uses language codes as keys and Page objects as values.
+ The returned dict uses language codes as keys and Page objects as values.
+
Do not call this routine directly, use Page.interwiki() method
instead.
@@ -454,11 +455,11 @@
def removeLanguageLinks(text, site=None, marker=''):
- """Return text with all interlanguage links removed.
+ """Return text with all inter-language links removed.
If a link to an unknown language is encountered, a warning is printed.
If a marker is defined, that string is placed at the location of the
- last occurence of an interwiki link (at the end if there are no
+ last occurrence of an interwiki link (at the end if there are no
interwiki links).
"""
@@ -480,12 +481,12 @@
def removeLanguageLinksAndSeparator(text, site=None, marker='', separator=''):
"""
- Return text with all interlanguage links, plus any preceeding whitespace
+ Return text with all inter-language links, plus any preceding whitespace
and separator occurrences removed.
If a link to an unknown language is encountered, a warning is printed.
If a marker is defined, that string is placed at the location of the
- last occurence of an interwiki link (at the end if there are no
+ last occurrence of an interwiki link (at the end if there are no
interwiki links).
"""
@@ -500,7 +501,7 @@
def replaceLanguageLinks(oldtext, new, site=None, addOnly=False,
template=False, template_subpage=False):
- """Replace interlanguage links in the text with a new set of links.
+ """Replace inter-language links in the text with a new set of links.
'new' should be a dict with the Site objects as keys, and Page or Link
objects as values (i.e., just like the dict returned by getLanguageLinks
@@ -699,7 +700,7 @@
def removeCategoryLinksAndSeparator(text, site=None, marker='', separator=''):
"""
- Return text with all category links, plus any preceeding whitespace
+ Return text with all category links, plus any preceding whitespace
and separator occurrences removed.
Put the string marker after the last replacement (at the end of the text
@@ -902,7 +903,7 @@
template in the page, with the template title as the first entry and a
dict of parameters as the second entry. Parameters are indexed by
strings; as in MediaWiki, an unnamed parameter is given a parameter name
- with an integer value corresponding to its position among the unnnamed
+ with an integer value corresponding to its position among the unnamed
parameters, and if this results multiple parameters with the same name
only the last value provided will be returned.
@@ -1117,11 +1118,11 @@
Note: It does not care whether a section string may contain spaces or
underlines. Both will match.
If a section parameter contains a internal link, it will match the
- section with or without a preleading colon which is required for a
+ section with or without a preceding colon which is required for a
text link e.g. for categories and files.
"""
- # match preleading colon for text links
+ # match preceding colon for text links
section = re.sub(r'\\\[\\\[(\\\:)?', '\[\[\:?', re.escape(section))
# match underscores and white spaces
section = re.sub(r'\\[ _]', '[ _]', section)
diff --git a/pywikibot/userinterfaces/terminal_interface_base.py b/pywikibot/userinterfaces/terminal_interface_base.py
index 56ea1f8..411cc31 100755
--- a/pywikibot/userinterfaces/terminal_interface_base.py
+++ b/pywikibot/userinterfaces/terminal_interface_base.py
@@ -230,7 +230,7 @@
Parameters:
* text - a Unicode string
* jumpIndex - an integer: position at which to put the caret
- * highlight - a substring; each occurence will be highlighted
+ * highlight - a substring; each occurrence will be highlighted
"""
try:
--
To view, visit https://gerrit.wikimedia.org/r/147100
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iae6bc175df0f5ba3d193c5e7ad3b5168f31c77d1
Gerrit-PatchSet: 1
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Loop improvement
......................................................................
Loop improvement
We don't need to run throug he loop completely when the arg is found.
Change-Id: Ie8eed3bf871c3a9a82b2e96cdc7f25d09c1a229d
---
M pywikibot/config2.py
1 file changed, 1 insertion(+), 0 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 2d3ce38..2f00d57 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -174,6 +174,7 @@
for arg in sys.argv[1:]:
if arg.startswith("-verbose") or arg == "-v":
print "The base directory is %s" % base_dir
+ break
family_files = {}
--
To view, visit https://gerrit.wikimedia.org/r/147385
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie8eed3bf871c3a9a82b2e96cdc7f25d09c1a229d
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: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Return the current directory if user-config.py exists in it
......................................................................
Return the current directory if user-config.py exists in it
It gives current directory overriding power over .pywikibot directory
Change-Id: I58169765676abd314be70de4d0aa522d1bf21358
---
M pywikibot/config2.py
1 file changed, 13 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index c79dd80..2d3ce38 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# (C) Rob W.W. Hooft, 2003
-# (C) Pywikibot team, 2003-2013
+# (C) Pywikibot team, 2003-2014
#
# Distributed under the terms of the MIT license.
#
@@ -114,22 +114,29 @@
provided in this argument
2. If the user has a PYWIKIBOT2_DIR environment variable, use the value
of it
- 3. Use (and if necessary create) a 'pywikibot' folder under
+ 3. If user-config presents in current directory, use the current directory
+ 4. Use (and if necessary create) a 'pywikibot' folder under
'Application Data' or 'AppData\Roaming' (Windows) or
'.pywikibot' directory (Unix and similar) under the user's home
directory.
"""
NAME = "pywikibot"
+ base_dir = ""
for arg in sys.argv[1:]:
if arg.startswith("-dir:"):
base_dir = arg[5:]
sys.argv.remove(arg)
break
+ current_exists = os.path.exists(
+ os.path.join(os.path.abspath("."), "user-config.py"))
+ if current_exists and "PYWIKIBOT2_DIR" not in os.environ and not base_dir:
+ base_dir = os.path.abspath(".")
+ return base_dir
else:
if "PYWIKIBOT2_DIR" in os.environ:
base_dir = os.environ["PYWIKIBOT2_DIR"]
- else:
+ elif not base_dir:
is_windows = sys.platform == 'win32'
home = os.path.expanduser("~")
if is_windows:
@@ -164,7 +171,9 @@
# Save base_dir for use by other modules
base_dir = _base_dir
-
+for arg in sys.argv[1:]:
+ if arg.startswith("-verbose") or arg == "-v":
+ print "The base directory is %s" % base_dir
family_files = {}
--
To view, visit https://gerrit.wikimedia.org/r/146692
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I58169765676abd314be70de4d0aa522d1bf21358
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
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: Mpaa <mpaa.wiki(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: reflinks.py - UnicodeDecodeError
......................................................................
reflinks.py - UnicodeDecodeError
Try to decode page text to bypass UnicodeDecodeError exception.
Maybe there is a better way to solve this issue.
Bug: 67410
Change-Id: Ia2051a2a80851b15b1a04a135763291bd633d4e3
---
M scripts/reflinks.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/reflinks.py b/scripts/reflinks.py
index 6a84381..232507b 100644
--- a/scripts/reflinks.py
+++ b/scripts/reflinks.py
@@ -681,7 +681,9 @@
elif u'.zh' in ref.link:
enc.append("gbk")
- u = linkedpagetext
+ if not 'utf-8' in enc:
+ enc.append('utf-8')
+ u = linkedpagetext.decode(enc[0]) # Bug 67410
# Retrieves the first non empty string inside <title> tags
for m in self.TITLE.finditer(u):
--
To view, visit https://gerrit.wikimedia.org/r/144969
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ia2051a2a80851b15b1a04a135763291bd633d4e3
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Beta16 <l.rabinelli(a)gmail.com>
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: jenkins-bot <>
Russell Blau has submitted this change and it was merged.
Change subject: (bug 66403) enable redirect.py follows section links
......................................................................
(bug 66403) enable redirect.py follows section links
site.getredirtarget() didn't take into account sections and also
page.getRedirectTarget() didn't find the section. This is a
breaking change againts compat behaviour and causes redirect.py
to fail. This patch looks for the section in the redirect target.
Additional improvements:
- normalize title by api result
- title encoding for Exception messages
Change-Id: I4b6d7f32fc1ec79eb962fa8d21d283b4fe783fbf
---
M pywikibot/site.py
1 file changed, 15 insertions(+), 6 deletions(-)
Approvals:
Russell Blau: Verified; Looks good to me, approved
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 971edc5..203bd7b 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1438,17 +1438,26 @@
if "query" not in result or "redirects" not in result["query"]:
raise RuntimeError(
"getredirtarget: No 'redirects' found for page %s."
- % title)
- redirmap = dict((item['from'], item['to'])
+ % title.encode(self.encoding()))
+ redirmap = dict((item['from'],
+ {'title': item['to'],
+ 'section': u'#' + item['tofragment']
+ if 'tofragment' in item and item['tofragment']
+ else ''})
for item in result['query']['redirects'])
+ if 'normalized' in result['query']:
+ for item in result['query']['normalized']:
+ if item['from'] == title:
+ title = item['to']
+ break
if title not in redirmap:
raise RuntimeError(
"getredirtarget: 'redirects' contains no key for page %s."
- % title)
- target_title = redirmap[title]
+ % title.encode(self.encoding()))
+ target_title = u'%(title)s%(section)s' % redirmap[title]
if target_title == title or "pages" not in result['query']:
# no "pages" element indicates a circular redirect
- raise pywikibot.CircularRedirect(redirmap[title])
+ raise pywikibot.CircularRedirect(target_title)
pagedata = list(result['query']['pages'].values())[0]
# there should be only one value in 'pages', and it is the target
if self.sametitle(pagedata['title'], target_title):
@@ -1542,7 +1551,7 @@
raise Error(
u"token: Query on page %s returned data on page [[%s]]"
% (page.title(withSection=False, asLink=True),
- item['title']))
+ item['title']))
api.update_page(page, item)
pywikibot.debug(unicode(item), _logger)
return item[tokentype + "token"]
--
To view, visit https://gerrit.wikimedia.org/r/138794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4b6d7f32fc1ec79eb962fa8d21d283b4fe783fbf
Gerrit-PatchSet: 5
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Alex S.H. Lin <alexsh(a)mail2000.com.tw>
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: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Russell Blau <russblau(a)imapmail.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>