diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py index 508f8bad9a..342e372c63 100644 --- a/pywikibot/__init__.py +++ b/pywikibot/__init__.py @@ -372,8 +372,8 @@ def precision(self): u""" Return the precision of the geo coordinate. - The precision is calculated if the Coordinate does not have a precision, - and self._dim is set. + The precision is calculated if the Coordinate does not have a + precision, and self._dim is set. When no precision and no self._dim exists, None is returned. @@ -385,13 +385,15 @@ def precision(self): In small angle approximation (and thus in radians): - M{Δλ ≈ Δpos / r_φ}, where r_φ is the radius of earth at the given latitude. + M{Δλ ≈ Δpos / r_φ}, where r_φ is the radius of earth at the given + latitude. Δλ is the error in longitude. M{r_φ = r cos φ}, where r is the radius of earth, φ the latitude Therefore:: - precision = math.degrees(self._dim/(radius*math.cos(math.radians(self.lat)))) + precision = math.degrees( + self._dim/(radius*math.cos(math.radians(self.lat)))) @rtype: float or None """ @@ -408,19 +410,24 @@ def precision(self, value): self._precision = value def precisionToDim(self): - """Convert precision from Wikibase to GeoData's dim and return the latter. + """ + Convert precision from Wikibase to GeoData's dim and return the latter. - dim is calculated if the Coordinate doesn't have a dimension, and precision is set. - When neither dim nor precision are set, ValueError is thrown. + dim is calculated if the Coordinate doesn't have a dimension, and + precision is set. When neither dim nor precision are set, ValueError + is thrown. Carrying on from the earlier derivation of precision, since - precision = math.degrees(dim/(radius*math.cos(math.radians(self.lat)))), we get - dim = math.radians(precision)*radius*math.cos(math.radians(self.lat)) - But this is not valid, since it returns a float value for dim which is an integer. - We must round it off to the nearest integer. + precision = math.degrees(dim/(radius*math.cos(math.radians(self.lat)))) + we get: + dim = math.radians( + precision)*radius*math.cos(math.radians(self.lat)) + But this is not valid, since it returns a float value for dim which is + an integer. We must round it off to the nearest integer. Therefore:: - dim = int(round(math.radians(precision)*radius*math.cos(math.radians(self.lat)))) + dim = int(round(math.radians( + precision)*radius*math.cos(math.radians(self.lat)))) @rtype: int or None """ @@ -430,7 +437,8 @@ def precisionToDim(self): radius = 6378137 self._dim = int( round( - math.radians(self._precision) * radius * math.cos(math.radians(self.lat)) + math.radians(self._precision) * radius * math.cos( + math.radians(self.lat)) ) ) return self._dim @@ -496,11 +504,15 @@ def __init__(self, year=None, month=None, day=None, readable string, e.g., 'hour'. If no precision is given, it is set according to the given time units. - Timezone information is given in three different ways depending on the time: - * Times after the implementation of UTC (1972): as an offset from UTC in minutes; - * Times before the implementation of UTC: the offset of the time zone from universal time; - * Before the implementation of time zones: The longitude of the place of - the event, in the range −180° to 180°, multiplied by 4 to convert to minutes. + Timezone information is given in three different ways depending on the + time: + * Times after the implementation of UTC (1972): as an offset from UTC + in minutes; + * Times before the implementation of UTC: the offset of the time zone + from universal time; + * Before the implementation of time zones: The longitude of the place + of the event, in the range −180° to 180°, multiplied by 4 to convert + to minutes. @param year: The year as a signed integer of between 1 and 16 digits. @type year: long @@ -516,11 +528,11 @@ def __init__(self, year=None, month=None, day=None, @type second: int @param precision: The unit of the precision of the time. @type precision: int or str - @param before: Number of units after the given time it could be, if uncertain. - The unit is given by the precision. + @param before: Number of units after the given time it could be, if + uncertain. The unit is given by the precision. @type before: int - @param after: Number of units before the given time it could be, if uncertain. - The unit is given by the precision. + @param after: Number of units before the given time it could be, if + uncertain. The unit is given by the precision. @type after: int @param timezone: Timezone information in minutes. @type timezone: int @@ -583,18 +595,19 @@ def fromTimestr(cls, datetimestr, precision=14, before=0, after=0, The timestamp differs from ISO 8601 in that: * The year is always signed and having between 1 and 16 digits; * The month, day and time are zero if they are unknown; - * The Z is discarded since time zone is determined from the timezone param. + * The Z is discarded since time zone is determined from the timezone + param. @param datetimestr: Timestamp in a format resembling ISO 8601, e.g. +2013-01-01T00:00:00Z @type datetimestr: str @param precision: The unit of the precision of the time. @type precision: int or str - @param before: Number of units after the given time it could be, if uncertain. - The unit is given by the precision. + @param before: Number of units after the given time it could be, if + uncertain. The unit is given by the precision. @type before: int - @param after: Number of units before the given time it could be, if uncertain. - The unit is given by the precision. + @param after: Number of units before the given time it could be, if + uncertain. The unit is given by the precision. @type after: int @param timezone: Timezone information in minutes. @type timezone: int @@ -623,11 +636,11 @@ def fromTimestamp(cls, timestamp, precision=14, before=0, after=0, @type timestamp: pywikibot.Timestamp @param precision: The unit of the precision of the time. @type precision: int or str - @param before: Number of units after the given time it could be, if uncertain. - The unit is given by the precision. + @param before: Number of units after the given time it could be, if + uncertain. The unit is given by the precision. @type before: int - @param after: Number of units before the given time it could be, if uncertain. - The unit is given by the precision. + @param after: Number of units before the given time it could be, if + uncertain. The unit is given by the precision. @type after: int @param timezone: Timezone information in minutes. @type timezone: int @@ -668,7 +681,8 @@ def toTimestamp(self): @return: Timestamp @rtype: pywikibot.Timestamp - @raises ValueError: instance value can not be represented using Timestamp + @raises ValueError: instance value can not be represented using + Timestamp """ if self.year <= 0: raise ValueError('You cannot turn BC dates into a Timestamp') @@ -716,7 +730,7 @@ class WbQuantity(_WbRepresentation): @staticmethod def _require_errors(site): """ - Check if the Wikibase site is so old it requires error bounds to be given. + Check if Wikibase site is so old it requires error bounds to be given. If no site item is supplied it raises a warning and returns True. @@ -729,7 +743,8 @@ def _require_errors(site): "WbQuantity now expects a 'site' parameter. This is needed to " "ensure correct handling of error bounds.") return False - return MediaWikiVersion(site.version()) < MediaWikiVersion('1.29.0-wmf.2') + return MediaWikiVersion( + site.version()) < MediaWikiVersion('1.29.0-wmf.2') @staticmethod def _todecimal(value): @@ -768,14 +783,14 @@ def __init__(self, amount, unit=None, error=None, site=None): Create a new WbQuantity object. @param amount: number representing this quantity - @type amount: string or Decimal. Other types are accepted, and converted - via str to Decimal. + @type amount: string or Decimal. Other types are accepted, and + converted via str to Decimal. @param unit: the Wikibase item for the unit or the entity URI of this - Wikibase item. + Wikibase item. @type unit: pywikibot.ItemPage, str or None @param error: the uncertainty of the amount (e.g. ±1) - @type error: same as amount, or tuple of two values, where the first value is - the upper error and the second is the lower error value. + @type error: same as amount, or tuple of two values, where the first + value is the upper error and the second is the lower error value. @param site: The Wikibase site @type site: pywikibot.site.DataSite """ @@ -909,7 +924,7 @@ def toWikibase(self): @classmethod def fromWikibase(cls, wb): """ - Create a WbMonolingualText from the JSON data given by the Wikibase API. + Create a WbMonolingualText from the JSON data given by Wikibase API. @param wb: Wikibase JSON @type wb: dict @@ -1320,8 +1335,8 @@ def _flush(stop=True): """ Drop this process from the throttle log, after pending threads finish. - Wait for the page-putter to flush its queue. Also drop this process from the - throttle log. Called automatically at Python exit. + Wait for the page-putter to flush its queue. Also drop this process from + the throttle log. Called automatically at Python exit. """ _logger = "wiki" diff --git a/pywikibot/config2.py b/pywikibot/config2.py index 161ee00c15..a575afc59e 100644 --- a/pywikibot/config2.py +++ b/pywikibot/config2.py @@ -33,7 +33,7 @@ """ # # (C) Rob W.W. Hooft, 2003 -# (C) Pywikibot team, 2003-2017 +# (C) Pywikibot team, 2003-2018 # # Distributed under the terms of the MIT license. # @@ -358,9 +358,11 @@ def exists(directory): if __no_user_config != '2': output(exc_text) else: - exc_text += " Please check that user-config.py is stored in the correct location.\n" - exc_text += " Directory where user-config.py is searched is determined as follows:\n\n" - exc_text += " " + get_base_dir.__doc__ + exc_text += ( + ' Please check that user-config.py is stored in the correct ' + 'location.\n' + ' Directory where user-config.py is searched is determined ' + 'as follows:\n\n ') + get_base_dir.__doc__ raise RuntimeError(exc_text) return base_dir @@ -391,7 +393,8 @@ def register_families_folder(folder_path): for file_name in os.listdir(folder_path): if file_name.endswith("_family.py"): family_name = file_name[:-len("_family.py")] - register_family_file(family_name, os.path.join(folder_path, file_name)) + register_family_file(family_name, os.path.join(folder_path, + file_name)) # Get the names of all known families, and initialize with empty dictionaries. @@ -928,7 +931,8 @@ def shortpath(path): def _win32_extension_command(extension): """Get the command from the Win32 registry for an extension.""" - fileexts_key = r'Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts' + fileexts_key = \ + r'Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts' key_name = fileexts_key + r'\.' + extension + r'\OpenWithProgids' _winreg = winreg # exists for git blame only; do not use try: @@ -946,8 +950,8 @@ def _win32_extension_command(extension): return cmd[:-1].strip() except WindowsError as e: # Catch any key lookup errors - output('Unable to detect program for file extension "{0}": {1!r}'.format( - extension, e)) + output('Unable to detect program for file extension "{0}": {1!r}' + .format(extension, e)) def _detect_win32_editor(): diff --git a/pywikibot/cosmetic_changes.py b/pywikibot/cosmetic_changes.py index a3dee44b3f..94af12a366 100755 --- a/pywikibot/cosmetic_changes.py +++ b/pywikibot/cosmetic_changes.py @@ -5,7 +5,9 @@ The changes are not supposed to change the look of the rendered wiki page. -If you wish to run this as an stand-alone script, use scripts/cosmetic_changes.py +If you wish to run this as an stand-alone script, use: + + scripts/cosmetic_changes.py For regular use, it is recommended to put this line into your user-config.py: @@ -46,11 +48,12 @@ or by adding a list to the given one: - cosmetic_changes_deny_script += ['your_script_name_1', 'your_script_name_2'] + cosmetic_changes_deny_script += ['your_script_name_1', + 'your_script_name_2'] """ # -# (C) xqt, 2009-2016 -# (C) Pywikibot team, 2006-2017 +# (C) xqt, 2009-2018 +# (C) Pywikibot team, 2006-2018 # # Distributed under the terms of the MIT license. # @@ -205,7 +208,8 @@ def __init__(self, site, diff=False, namespace=None, pageTitle=None, try: self.namespace = self.site.namespaces.resolve(namespace).pop(0) except (KeyError, TypeError, IndexError): - raise ValueError('%s needs a valid namespace' % self.__class__.__name__) + raise ValueError('{0} needs a valid namespace' + .format(self.__class__.__name__)) self.template = (self.namespace == 10) self.talkpage = self.namespace >= 0 and self.namespace % 2 == 1 self.title = pageTitle @@ -269,7 +273,8 @@ def change(self, text): new_text = self._change(text) except Exception as e: if self.ignore == CANCEL_PAGE: - pywikibot.warning(u'Skipped "{0}", because an error occurred.'.format(self.title)) + pywikibot.warning('Skipped "{0}", because an error occurred.' + .format(self.title)) pywikibot.exception(e) return False else: @@ -317,7 +322,7 @@ def standardizePageFooter(self, text): self.site.code not in ('et', 'it', 'bg', 'ru'): categories = textlib.getCategoryLinks(text, site=self.site) - if not self.talkpage: # and pywikibot.calledModuleName() <> 'interwiki': + if not self.talkpage: subpage = False if self.template: loc = None @@ -340,11 +345,6 @@ def standardizePageFooter(self, text): # e.g. using categories.sort() # TODO: Taking main cats to top - # for name in categories: - # if (re.search(u"(.+?)\|(.{,1}?)",name.title()) or - # name.title() == name.title().split(":")[0] + title): - # categories.remove(name) - # categories.insert(0, name) text = textlib.replaceCategoryLinks(text, categories, site=self.site) # Adding the interwiki @@ -373,8 +373,8 @@ def translateAndCapitalizeNamespaces(self, text): namespaces = list(namespace) thisNs = namespaces.pop(0) if namespace.id == 6 and family.name == 'wikipedia': - if self.site.code in ('en', 'fr') and \ - MediaWikiVersion(self.site.version()) >= MediaWikiVersion('1.14'): + if self.site.code in ('en', 'fr') and MediaWikiVersion( + self.site.version()) >= MediaWikiVersion('1.14'): # do not change "Image" on en-wiki and fr-wiki assert u'Image' in namespaces namespaces.remove(u'Image') @@ -615,11 +615,12 @@ def resolveHtmlEntities(self, text): def removeUselessSpaces(self, text): """Cleanup multiple or trailing spaces.""" - exceptions = ['comment', 'math', 'nowiki', 'pre', 'startspace', 'table'] + exceptions = ['comment', 'math', 'nowiki', 'pre', 'startspace', + 'table'] if self.site.sitename != 'wikipedia:cs': exceptions.append('template') - text = textlib.replaceExcept(text, r'(?m)[\t ]+( |$)', r'\1', exceptions, - site=self.site) + text = textlib.replaceExcept(text, r'(?m)[\t ]+( |$)', r'\1', + exceptions, site=self.site) return text def removeNonBreakingSpaceBeforePercent(self, text): @@ -658,15 +659,16 @@ def putSpacesInLists(self, text): Add a space between the * or # and the text. NOTE: This space is recommended in the syntax help on the English, - German, and French Wikipedia. It might be that it is not wanted on other - wikis. If there are any complaints, please file a bug report. + German, and French Wikipedia. It might be that it is not wanted on + other wikis. If there are any complaints, please file a bug report. """ if not self.template: - exceptions = ['comment', 'math', 'nowiki', 'pre', 'source', 'template', - 'timeline', self.site.redirectRegex()] + exceptions = ['comment', 'math', 'nowiki', 'pre', 'source', + 'template', 'timeline', self.site.redirectRegex()] text = textlib.replaceExcept( text, - r'(?m)^(?P[:;]*(\*+|#+)[:;\*#]*)(?P[^\s\*#:;].+?)', + r'(?m)' + r'^(?P[:;]*(\*+|#+)[:;\*#]*)(?P[^\s\*#:;].+?)', r'\g \g', exceptions) return text @@ -797,7 +799,8 @@ def replace_header(match): def fixReferences(self, text): """Fix references tags.""" - # See also https://en.wikipedia.org/wiki/User:AnomieBOT/source/tasks/OrphanReferenceFixer.pm + # See also + # https://en.wikipedia.org/wiki/User:AnomieBOT/source/tasks/OrphanReferenceFixer.pm exceptions = ['nowiki', 'comment', 'math', 'pre', 'source', 'startspace'] @@ -825,7 +828,8 @@ def fixStyle(self, text): def fixTypo(self, text): """Fix units.""" exceptions = ['nowiki', 'comment', 'math', 'pre', 'source', - 'startspace', 'gallery', 'hyperlink', 'interwiki', 'link'] + 'startspace', 'gallery', 'hyperlink', 'interwiki', + 'link'] # change ccm -> cm³ text = textlib.replaceExcept(text, r'(\d)\s*(?: )?ccm', r'\1 cm³', exceptions, @@ -835,7 +839,8 @@ def fixTypo(self, text): pattern = re.compile(u'«.*?»', re.UNICODE) exceptions.append(pattern) text = textlib.replaceExcept(text, r'(\d)\s*(?: )?[º°]([CF])', - r'\1 °\2', exceptions, site=self.site) + r'\1 °\2', exceptions, + site=self.site) text = textlib.replaceExcept(text, u'º([CF])', u'°' + r'\1', exceptions, site=self.site) @@ -874,7 +879,8 @@ def fixArabicLetters(self, text): # not to let bot edits in latin content exceptions.append(re.compile(u"[^%(fa)s] *?\"*? *?, *?[^%(fa)s]" % {'fa': faChrs})) - text = textlib.replaceExcept(text, ',', '،', exceptions, site=self.site) + text = textlib.replaceExcept(text, ',', '،', exceptions, + site=self.site) if self.site.code == 'ckb': text = textlib.replaceExcept(text, '\u0647([.\u060c_<\\]\\s])', @@ -915,7 +921,8 @@ def commonsfiledesc(self, text): It is working according to [1] and works only on pages in the file namespace on the Wikimedia Commons. - [1]: https://commons.wikimedia.org/wiki/Commons:Tools/pywiki_file_description_cleanup + [1]: + https://commons.wikimedia.org/wiki/Commons:Tools/pywiki_file_description_cleanup """ if self.site.sitename != 'commons:commons' or self.namespace == 6: return @@ -932,14 +939,16 @@ def commonsfiledesc(self, text): r"\1== {{int:license-header}} ==", exceptions, True) text = textlib.replaceExcept( text, - r"([\r\n])\=\= *(Licensing|License information|{{int:license}}) *\=\=", + r'([\r\n])' + r'\=\= *(Licensing|License information|{{int:license}}) *\=\=', r"\1== {{int:license-header}} ==", exceptions, True) # frequent field values to {{int:}} versions text = textlib.replaceExcept( text, r'([\r\n]\|[Ss]ource *\= *)' - r'(?:[Oo]wn work by uploader|[Oo]wn work|[Ee]igene [Aa]rbeit) *([\r\n])', + r'(?:[Oo]wn work by uploader|[Oo]wn work|[Ee]igene [Aa]rbeit) *' + r'([\r\n])', r'\1{{own}}\2', exceptions, True) text = textlib.replaceExcept( text, @@ -960,7 +969,8 @@ def commonsfiledesc(self, text): # duplicated section headers text = textlib.replaceExcept( text, - r'([\r\n]|^)\=\= *{{int:filedesc}} *\=\=(?:[\r\n ]*)\=\= *{{int:filedesc}} *\=\=', + r'([\r\n]|^)\=\= *{{int:filedesc}} *\=\=(?:[\r\n ]*)\=\= *' + r'{{int:filedesc}} *\=\=', r'\1== {{int:filedesc}} ==', exceptions, True) text = textlib.replaceExcept( text, diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py index 2e456fbaa7..bc1e8f3c96 100644 --- a/pywikibot/exceptions.py +++ b/pywikibot/exceptions.py @@ -80,7 +80,7 @@ - FamilyMaintenanceWarning: missing information in family definition """ # -# (C) Pywikibot team, 2008-2017 +# (C) Pywikibot team, 2008-2018 # # Distributed under the terms of the MIT license. # @@ -442,7 +442,8 @@ class ArticleExistsConflict(EditConflict): """Page already exists.""" - message = u"Destination article %s already exists and is not a redirect to the source article" + message = ('Destination article %s already exists and is not a redirect ' + 'to the source article') pass @@ -451,7 +452,8 @@ class SpamfilterError(PageSaveRelatedError): """Page save failed because MediaWiki detected a blacklisted spam URL.""" - message = "Edit to page %(title)s rejected by spam filter due to content:\n%(url)s" + message = ('Edit to page %(title)s rejected by spam filter due to ' + 'content:\n%(url)s') def __init__(self, page, url): """Constructor.""" diff --git a/pywikibot/family.py b/pywikibot/family.py index 0dae080321..a4c49f0729 100644 --- a/pywikibot/family.py +++ b/pywikibot/family.py @@ -170,14 +170,16 @@ def __init__(self): 'crh': u'[a-zâçğıñöşüа-яё“»]*', 'cs': u'[a-záčďéěíňóřšťúůýž]*', 'csb': u'[a-zęóąśłżźćńĘÓĄŚŁŻŹĆŃ]*', - 'cu': u'[a-zабвгдеєжѕзїіıићклмнопсстѹфхѡѿцчшщъыьѣюѥѧѩѫѭѯѱѳѷѵґѓђёјйљњќуўџэ҄я“»]*', + 'cu': ('[a-zабвгдеєжѕзїіıићклмнопсстѹфхѡѿцчшщъыьѣюѥѧѩѫѭѯѱѳѷѵґѓђё' + 'јйљњќуўџэ҄я“»]*'), 'cv': u'[a-zа-яĕçăӳ"»]*', 'cy': u'[àáâèéêìíîïòóôûŵŷa-z]*', 'da': u'[a-zæøå]*', 'de': u'[a-zäöüß]*', 'din': '[äëɛɛ̈éɣïŋöɔɔ̈óa-z]*', 'dsb': u'[äöüßa-z]*', - 'el': u'[a-zαβγδεζηθικλμνξοπρστυφχψωςΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩάέήίόύώϊϋΐΰΆΈΉΊΌΎΏΪΫ]*', + 'el': ('[a-zαβγδεζηθικλμνξοπρστυφχψωςΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩάέή' + 'ίόύώϊϋΐΰΆΈΉΊΌΎΏΪΫ]*'), 'eml': u'[a-zàéèíîìóòúù]*', 'es': u'[a-záéíóúñ]*', 'eu': u'[a-záéíóúñ]*', @@ -209,7 +211,8 @@ def __init__(self): 'it': u'[a-zàéèíîìóòúù]*', 'ka': u'[a-zაბგდევზთიკლმნოპჟრსტუფქღყშჩცძწჭხჯჰ“»]*', 'kbp': '[a-zàâçéèêîôûäëïöüùÇÉÂÊÎÔÛÄËÏÖÜÀÈÙ]*', - 'kk': u'[a-zäçéğıïñöşüýʺʹа-яёәғіқңөұүһٴابپتجحدرزسشعفقكلمنڭەوۇۋۆىيچھ“»]*', + 'kk': ('[a-zäçéğıïñöşüýʺʹа-яёәғіқңөұүһ' + 'ٴابپتجحدرزسشعفقكلمنڭەوۇۋۆىيچھ“»]*'), 'kl': u'[a-zæøå]*', 'koi': u'[a-zабвгдеёжзийклмнопрстуфхцчшщъыьэюя]*', 'krc': u'[a-zабвгдеёжзийклмнопрстуфхцчшщъыьэюя]*', @@ -251,7 +254,8 @@ def __init__(self): 'oc': u'[a-zàâçéèêîôû]*', 'olo': '[a-zčČšŠžŽäÄöÖ]*', 'or': u'[a-z଀-୿]*', - 'pa': u'[ਁਂਃਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਲ਼ਵਸ਼ਸਹ਼ਾਿੀੁੂੇੈੋੌ੍ਖ਼ਗ਼ਜ਼ੜਫ਼ੰੱੲੳa-z]*', + 'pa': ('[ਁਂਃਅਆਇਈਉਊਏਐਓਔਕਖਗਘਙਚਛਜਝਞਟਠਡਢਣਤਥਦਧਨਪਫਬਭਮਯਰਲਲ਼ਵਸ਼ਸਹ਼ਾ' + 'ਿੀੁੂੇੈੋੌ੍ਖ਼ਗ਼ਜ਼ੜਫ਼ੰੱੲੳa-z]*'), 'pcd': u'[a-zàâçéèêîôûäëïöüùÇÉÂÊÎÔÛÄËÏÖÜÀÈÙ]*', 'pdc': u'[äöüßa-z]*', 'pfl': u'[äöüßa-z]*', @@ -274,7 +278,8 @@ def __init__(self): 'sh': u'[a-zčćđžš]*', 'sk': u'[a-záäčďéíľĺňóôŕšťúýž]*', 'sl': u'[a-zčćđžš]*', - 'sr': u'[abvgdđežzijklljmnnjoprstćufhcčdžšабвгдђежзијклљмнњопрстћуфхцчџш]*', + 'sr': ('[abvgdđežzijklljmnnjoprstćufhcčdžšабвгдђежзијклљмнњопрстћу' + 'фхцчџш]*'), 'srn': u'[a-zäöüïëéèà]*', 'stq': u'[äöüßa-z]*', 'sv': u'[a-zåäöéÅÄÖÉ]*', @@ -715,7 +720,7 @@ def __init__(self): '_default': [] } - # A list of languages that use hard (instead of soft) category redirects + # A list of languages that use hard (not soft) category redirects self.use_hard_category_redirects = [] # A list of disambiguation template names in different languages @@ -851,10 +856,11 @@ def __init__(self): 'nrm', 'nv', 'ny', 'oc', 'om', 'pag', 'pam', 'pap', 'pcd', 'pdc', 'pfl', 'pih', 'pl', 'pms', 'pt', 'qu', 'rm', 'rn', 'ro', 'roa-rup', 'roa-tara', 'rw', 'sc', 'scn', 'sco', 'se', 'sg', - 'simple', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'srn', 'ss', 'st', - 'stq', 'su', 'sv', 'sw', 'szl', 'tet', 'tl', 'tn', 'to', 'tpi', - 'tr', 'ts', 'tum', 'tw', 'ty', 'uz', 've', 'vec', 'vi', 'vls', - 'vo', 'wa', 'war', 'wo', 'xh', 'yo', 'zea', 'zh-min-nan', 'zu', + 'simple', 'sk', 'sl', 'sm', 'sn', 'so', 'sq', 'srn', 'ss', + 'st', 'stq', 'su', 'sv', 'sw', 'szl', 'tet', 'tl', 'tn', 'to', + 'tpi', 'tr', 'ts', 'tum', 'tw', 'ty', 'uz', 've', 'vec', 'vi', + 'vls', 'vo', 'wa', 'war', 'wo', 'xh', 'yo', 'zea', + 'zh-min-nan', 'zu', # languages using multiple scripts, including latin 'az', 'chr', 'ckb', 'ha', 'iu', 'kk', 'ku', 'rmy', 'sh', 'sr', 'tt', 'ug', 'za' @@ -1123,8 +1129,8 @@ def base_url(self, code, uri, protocol=None): @param code: The site code @param uri: The absolute path after the hostname - @param protocol: The protocol which is used. If None it'll determine the - protocol from the code. + @param protocol: The protocol which is used. If None it'll determine + the protocol from the code. @return: The full URL @rtype: str """ @@ -1633,7 +1639,8 @@ def __init__(self): @property def domain(self): """Domain property.""" - if self.name in self.multi_language_content_families + self.other_content_families: + if self.name in (self.multi_language_content_families + + self.other_content_families): return self.name + '.org' elif self.name in self.wikimedia_org_families: return 'wikimedia.org' diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py index e82196964f..3a68c675f4 100644 --- a/pywikibot/fixes.py +++ b/pywikibot/fixes.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """File containing all standard fixes.""" # -# (C) Pywikibot team, 2008-2017 +# (C) Pywikibot team, 2008-2018 # # Distributed under the terms of the MIT license. # @@ -59,18 +59,23 @@ (r'(?i)(.*?)', r"''\1''"), # horizontal line without attributes in a single line (r'(?i)([\r\n])([\r\n])', r'\1----\2'), - # horizontal line without attributes with more text in the same line + # horizontal line without attributes with more text in same line # (r'(?i) + +', r'\r\n----\r\n'), # horizontal line with attributes; can't be done with wiki syntax # so we only make it XHTML compliant (r'(?i)
/]+?)>', r'
'), # a header where only spaces are in the same line - (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', r"\1= \2 =\3"), - (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', r"\1== \2 ==\3"), - (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', r"\1=== \2 ===\3"), - (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', r"\1==== \2 ====\3"), - (r'(?i)([\r\n]) *
*([^<]+?) *
*([\r\n])', r"\1===== \2 =====\3"), - (r'(?i)([\r\n]) *
*([^<]+?) *
*([\r\n])', r"\1====== \2 ======\3"), + (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', r'\1= \2 =\3'), + (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', + r'\1== \2 ==\3'), + (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', + r'\1=== \2 ===\3'), + (r'(?i)([\r\n]) *

*([^<]+?) *

*([\r\n])', + r'\1==== \2 ====\3'), + (r'(?i)([\r\n]) *
*([^<]+?) *
*([\r\n])', + r'\1===== \2 =====\3'), + (r'(?i)([\r\n]) *
*([^<]+?) *
*([\r\n])', + r'\1====== \2 ======\3'), # TODO: maybe we can make the bot replace

tags with \r\n's. ], 'exceptions': { @@ -102,12 +107,14 @@ # zusammengesetztes Wort, Bindestrich wird durchgeschleift (r'(?\d+m', # bei chemischen Formeln - r'\([A-Z][A-Za-z]*(,[A-Z][A-Za-z]*(.*?|.*?|))+\)' + r'\([A-Z][A-Za-z]*(,[A-Z][A-Za-z]*' + r'(.*?|.*?|))+\)' # chemische Formel, z. B. AuPb(Pb,Sb,Bi)Te. # Hier sollen keine Leerzeichen hinter die Kommata. ], @@ -251,7 +262,8 @@ # dash in external link, where the correct end of the URL can # be detected from the file extension. It is very unlikely that # this will cause mistakes. - (r'\[(?Phttps?://[^\|\] ]+?(\.pdf|\.html|\.htm|\.php|\.asp|\.aspx|\.jsp)) *\|' + (r'\[(?Phttps?://[^\|\] ]+?' + r'(\.pdf|\.html|\.htm|\.php|\.asp|\.aspx|\.jsp)) *\|' r' *(?P