Dalba has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/297184

Change subject: solve_disambiguation.py: Extend docstrings and add some type 
hints
......................................................................

solve_disambiguation.py: Extend docstrings and add some type hints

Change-Id: I347b282ccad085cac7e66e1ad67770d3e8304500
---
M scripts/solve_disambiguation.py
1 file changed, 76 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/84/297184/1

diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index c0003fa..0a118f6 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -352,11 +352,15 @@
 
 
 def correctcap(link, text):
-    """
-    Capitalize link.
+    """Return the link capitalized/uncapitalized according to the text.
 
-    If text links to a page with title link uncapitalized, uncapitalize link,
-    otherwise capitalize it
+    @param link: link page.
+    @type link: pywikibot.Page
+    @type text: str
+    @return: uncapitalized title of the link if the text links to the link
+        with an uncapitalized title, else capitalized.
+    @rtype: str
+
     """
     linkupper = link.title()
     linklower = first_lower(linkupper)
@@ -371,7 +375,15 @@
     """Referring Page generator, with an ignore manager."""
 
     def __init__(self, disambPage, primary=False, minimum=0, main_only=False):
-        """Constructor."""
+        """Constructor.
+
+        @type disambPage: pywikibot.Page
+        @type primary: bool
+        @type minimum: int
+        @type main_only: bool
+        @rtype: None
+
+        """
         self.disambPage = disambPage
         # if run with the -primary argument, enable the ignore manager
         self.primaryIgnoreManager = PrimaryIgnoreManager(disambPage,
@@ -423,7 +435,13 @@
     """
 
     def __init__(self, disambPage, enabled=False):
-        """Constructor."""
+        """Constructor.
+
+        @type disambPage: pywikibot.Page
+        @type enabled: bool
+        @rtype: bool
+
+        """
         self.disambPage = disambPage
         self.enabled = enabled
         self.ignorelist = []
@@ -433,7 +451,12 @@
             self._read_ignorelist(folder)
 
     def _read_ignorelist(self, folder):
-        """Read pages to be ignored from file."""
+        """Read pages to be ignored from file.
+
+        @type folder: str
+        @rtype: None
+
+        """
         filename = os.path.join(
             folder, self.disambPage.title(as_filename=True) + '.txt')
         try:
@@ -452,11 +475,21 @@
             pass
 
     def isIgnored(self, refPage):
-        """Return if refPage is to be ignored."""
+        """Return if refPage is to be ignored.
+
+        @type refPage: pywikibot.Page
+        @rtype: bool
+
+        """
         return self.enabled and refPage.title(asUrl=True) in self.ignorelist
 
     def ignore(self, refPage):
-        """Write page to ignorelist."""
+        """Write page to ignorelist.
+
+        @type refPage: pywikibot.Page
+        @rtype: None
+
+        """
         if self.enabled:
             # Skip this occurrence next time.
             filename = config.datafilepath(
@@ -487,7 +520,16 @@
     """Edit the text."""
 
     def __init__(self, option, shortcut, text, start, title):
-        """Constructor."""
+        """Constructor.
+
+        @type option: str
+        @type shortcut: str
+        @type text: str
+        @type start: int
+        @type title: str
+        @rtype: None
+
+        """
         super(EditOption, self).__init__(option, shortcut)
         self._text = text
         self._start = start
@@ -495,7 +537,11 @@
 
     @property
     def stop(self):
-        """Return whether if user didn't press cancel and changed it."""
+        """Return whether if user didn't press cancel and changed it.
+
+        @rtype: bool
+
+        """
         return self.new_text and self.new_text != self._text
 
     def result(self, value):
@@ -643,15 +689,18 @@
                                 flags=re.X)
 
     def treat(self, refPage, disambPage):
-        """
-        Treat a page.
+        """Treat a page.
 
-        Parameters:
-            disambPage - The disambiguation page or redirect we don't want
-                anything to link to
-            refPage - A page linking to disambPage
-        Returns False if the user pressed q to completely quit the program.
-        Otherwise, returns True.
+        Pass disambPage and its redirect to self.inner_treat.
+
+        @param disambPage: the disambiguation page or redirect we don't want
+            anything to link to
+        @type disambPage: pywikibot.Page
+        @param refPage: A page linking to disambPage
+        @type refPage: pywikibot.Page
+        @return: False if the user pressed q to completely quit the program,
+            True otherwise.
+        @rtype: bool
 
         """
         # TODO: break this function up into subroutines!
@@ -904,7 +953,14 @@
         return True
 
     def findAlternatives(self, disambPage):
-        """Look for alternative links of disambiguation pages."""
+        """Extend self.alternatives using correctcap of disambPage.linkedPages.
+
+        @param disambPage: The disabiguation page.
+        @type disambPage: pywikibot.Page
+        @return: True if everything goes fine, False otherwise.
+        @rtype: bool
+
+        """
         if disambPage.isRedirectPage() and not self.primary:
             if (disambPage.site.lang in self.primary_redir_template and
                     self.primary_redir_template[disambPage.site.lang]

-- 
To view, visit https://gerrit.wikimedia.org/r/297184
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I347b282ccad085cac7e66e1ad67770d3e8304500
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.w...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to