Ladsgroup has uploaded a new change for review.
https://gerrit.wikimedia.org/r/157203
Change subject: PEP257 on pywikibot folder part I
......................................................................
PEP257 on pywikibot folder part I
files: family, fixes, i18n and interwiki_graph
Checked by hand and added some suggestions based on this change:
I910fdd7ce36752fa44b9a6654d7b8509e5020dee
Change-Id: I1fb9267828d68743d0a4a8533d7b0433e7205ac6
---
M pywikibot/family.py
M pywikibot/fixes.py
M pywikibot/i18n.py
M pywikibot/interwiki_graph.py
4 files changed, 42 insertions(+), 32 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/03/157203/1
diff --git a/pywikibot/family.py b/pywikibot/family.py
index f7affb1..eb838ca 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -841,9 +841,10 @@
return list(self.langs.keys())
def _addlang(self, code, location, namespaces={}):
- """Add a new language to the langs and namespaces of the family.
- This is supposed to be called in the constructor of the family.
+ """
+ Add a new language to the langs and namespaces of the family.
+ This is supposed to be called in the constructor of the family.
"""
self.langs[code] = location
# for num, val in namespaces.items():
@@ -861,7 +862,6 @@
[[MediaWiki:Linktrail]], because the MW software currently uses a
built-in linktrail from its message files and ignores the wiki
value.
-
"""
if code in self.linktrails:
return self.linktrails[code]
@@ -919,6 +919,10 @@
"""
Can be overridden to return 'https'. Other protocols are not supported.
+ @param code: language code
+ @type code: string
+ @return: protocol that this family uses
+ @rtype: string
"""
return 'http'
@@ -940,7 +944,6 @@
The default value is the one used on Wikimedia Foundation wikis,
but needs to be overridden in the family file for any wiki that
uses a different value.
-
"""
return '/w'
@@ -971,21 +974,21 @@
# Which version of MediaWiki is used?
def version(self, code):
""" Return MediaWiki version number as a string.
- Use LooseVersion from distutils.version to compare version strings.
+ Use LooseVersion from distutils.version to compare version strings.
"""
# Here we return the latest mw release for downloading
return '1.23.2'
@deprecated("version()")
def versionnumber(self, code):
- """ DEPRECATED, use version() instead and use
- distutils.version.LooseVersion to compare version strings.
+ """ DEPRECATED, use version() instead.
+
+ Use distutils.version.LooseVersion to compare version strings.
Return an int identifying MediaWiki version.
Currently this is implemented as returning the minor version
number; i.e., 'X' in version '1.X.Y'
-
"""
R = re.compile(r"(\d+).(\d+)")
M = R.search(self.version(code))
@@ -995,22 +998,20 @@
return 1000 * int(M.group(1)) + int(M.group(2)) - 1000
def code2encoding(self, code):
- """Return the encoding for a specific language wiki"""
+ """Return the encoding for a specific language wiki."""
return 'utf-8'
def code2encodings(self, code):
- """Return a list of historical encodings for a specific language
- wiki"""
+ """Return list of historical encodings for a specific language Wiki."""
return self.code2encoding(code),
# aliases
def encoding(self, code):
- """Return the encoding for a specific language wiki"""
+ """Return the encoding for a specific language Wiki."""
return self.code2encoding(code)
def encodings(self, code):
- """Return a list of historical encodings for a specific language
- wiki"""
+ """Return list of historical encodings for a specific language Wiki."""
return self.code2encodings(code)
def __cmp__(self, otherfamily):
@@ -1029,14 +1030,14 @@
return 'Family("%s")' % self.name
def RversionTab(self, code):
- """Change this to some regular expression that shows the page we
+ """
+ Change this to some regular expression that shows the page we
found is an existing page, in case the normal regexp does not work.
-
"""
return None
def has_query_api(self, code):
- """Is query.php installed in the wiki?"""
+ """Check query.php installed in the wiki."""
return False
def shared_image_repository(self, code):
@@ -1050,22 +1051,30 @@
@deprecated("Site.getcurrenttime()")
def server_time(self, code):
"""
- DEPRECATED, use Site.getcurrenttime() instead
- Return a datetime object representing server time"""
+ DEPRECATED, use Site.getcurrenttime() instead.
+
+ Return a datetime object representing server time
+ """
return pywikibot.Site(code, self).getcurrenttime()
def isPublic(self, code):
- """Does the wiki require logging in before viewing it?"""
+ """Check the wiki require logging in before viewing it."""
return True
def post_get_convert(self, site, getText):
- """Do a conversion on the retrieved text from the wiki
- i.e. Esperanto X-conversion """
+ """
+ Do a conversion on the retrieved text from the Wiki.
+
+ i.e. Esperanto X-conversion
+ """
return getText
def pre_put_convert(self, site, putText):
- """Do a conversion on the text to insert on the wiki
- i.e. Esperanto X-conversion """
+ """
+ Do a conversion on the text to insert on the Wiki.
+
+ i.e. Esperanto X-conversion
+ """
return putText
@@ -1084,9 +1093,10 @@
]
def version(self, code):
- """Return Wikimedia projects version number as a string.
- Use LooseVersion from distutils.version to compate versions.
+ """
+ Return Wikimedia projects version number as a string.
+ Use LooseVersion from distutils.version to compate versions.
"""
# Here we return the latest mw release of wikimedia projects
return '1.24wmf17'
diff --git a/pywikibot/fixes.py b/pywikibot/fixes.py
index b5e8002..8b3f21b 100644
--- a/pywikibot/fixes.py
+++ b/pywikibot/fixes.py
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
-"""
-File containing all standard fixes
-
-"""
+"""File containing all standard fixes"""
#
# (C) Pywikibot team, 2008-2010
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index cb6bd71..ffd143a 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -229,7 +229,8 @@
class TranslationError(Error):
- """ Raised when no correct translation could be found """
+ """Raised when no correct translation could be found."""
+
pass
diff --git a/pywikibot/interwiki_graph.py b/pywikibot/interwiki_graph.py
index 3fec68b..b0219d0 100644
--- a/pywikibot/interwiki_graph.py
+++ b/pywikibot/interwiki_graph.py
@@ -129,7 +129,9 @@
def createGraph(self):
"""
- See http://meta.wikimedia.org/wiki/Interwiki_graphs
+ Create graph of the interwiki links.
+
+ For more info see http://meta.wikimedia.org/wiki/Interwiki_graphs
"""
pywikibot.output(u'Preparing graph for %s'
% self.subject.originPage.title())
--
To view, visit https://gerrit.wikimedia.org/r/157203
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I1fb9267828d68743d0a4a8533d7b0433e7205ac6
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits