jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/548817 )
Change subject: component: docstring update patch for comments ......................................................................
component: docstring update patch for comments
Update per feedback
Bug: T184115 Change-Id: I3047f6b880308ee8adfb6d931916958a76646255 --- M pywikibot/login.py M scripts/add_text.py M scripts/category.py M scripts/imagetransfer.py 4 files changed, 94 insertions(+), 8 deletions(-)
Approvals: Zhuyifei1999: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/login.py b/pywikibot/login.py index 9b9ed2f..389ac12 100644 --- a/pywikibot/login.py +++ b/pywikibot/login.py @@ -173,9 +173,10 @@ """ Store cookie data.
- The argument data is the raw data, as returned by getCookie(). + @param data: The raw data as returned by getCookie() + @type data: str
- Returns nothing. + @return: None """ # THIS IS OVERRIDDEN IN data/api.py filename = config.datafilepath('pywikibot.lwp') diff --git a/scripts/add_text.py b/scripts/add_text.py index 386dd44..3eec3a8 100755 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -76,7 +76,19 @@
def get_text(page, old, create): - """Get the old text.""" + """ + Get text on page. If old is not None, return old. + + @param page: The page to get text from + @type page: pywikibot.page.BasePage + @param old: If not None, this parameter is returned instead + of fetching text from the page + @type old: str + @param create: Create the page if it doesn't exist + @type create: bool + @return: The page's text or old parameter if not None + @rtype: str + """ if old is None: try: text = page.get() @@ -98,7 +110,23 @@
def put_text(page, new, summary, count, asynchronous=False): - """Save the new text.""" + """ + Save the new text. + + @param page: The page to update and save + @type page: pywikibot.page.BasePage + @param new: The new text for the page + @type new: str + @param summary: Summary of page changes. + @type summary: str + @param count: Maximum num attempts to reach the server + @type count: int + @param asynchronous: Save the page asynchronously + @type asynchronous: bool + @return: True if successful, False if unsuccessful, None if + waiting for server + @rtype: bool / None + """ page.text = new try: page.save(summary=summary, asynchronous=asynchronous, @@ -132,7 +160,34 @@ """ Add text to a page.
- @rtype: tuple of (text, newtext, always) + @param page: The page to add text to + @type page: pywikibot.page.BasePage + @param addText: Text to add + @type addText: str + @param summary: Summary of changes. If None, beginning of addText is used. + @type summary: str + @param regexSkip: Abort if text on page matches + @type regexSkip: str + @param regexSkipUrl: Abort if full url matches + @type regexSkipUrl: str + @param always: Always add text without user confirmation + @type always: bool + @param up: If True, add text to top of page, else add at bottom. + @type up: bool + @param putText: If True, save changes to the page, else return + (text, newtext, always) + @type putText: bool + @param oldTextGiven: If None fetch page text, else use this text + @type oldTextGiven: str + @param reorderEnabled: If True place text above categories and + interwiki, else place at page bottom. No effect if up = False. + @type reorderEnabled: bool + @param create: Create page if it does not exist + @type create: bool + @return: If putText=True: (success, success, always) + else: (text, newtext, always) + @rtype: Tuple of (bool, bool, bool) or (str, str, bool) + depending on value of putText parameter """ site = page.site if not summary: diff --git a/scripts/category.py b/scripts/category.py index e07d71e..cc67ebc 100755 --- a/scripts/category.py +++ b/scripts/category.py @@ -651,7 +651,8 @@ self.move_comment = move_comment if move_comment else self.comment
def run(self): - """The main bot function that does all the work. + """ + The main bot function that does all the work.
For readability it is split into several helper functions: - _movecat() @@ -718,6 +719,12 @@
Do not use this function from outside the class. Automatically marks the pages if they can't be removed due to missing permissions. + + @param moved_page: Category page to delete + @param moved_talk: Talk page to delete + @type moved_page: pywikibot.page.BasePage + @type moved_talk: pywikibot.page.BasePage + """ if moved_page and self.oldcat.exists(): self.oldcat.delete(self.deletion_comment, not self.batch, @@ -755,7 +762,19 @@
@staticmethod def check_move(name, old_page, new_page): - """Return if the old page can be safely moved to the new page.""" + """Return if the old page can be safely moved to the new page. + + @param name: Title of the new page + @type name: str + @param old_page: Page to be moved + @type old_page: pywikibot.page.BasePage + @param new_page: Page to be moved to + @type new_page: pywikibot.page.BasePage + @return: True if possible to move page, False if not page move + not possible + @rtype: bool + + """ move_possible = True if new_page and new_page.exists(): pywikibot.warning("The {0} target '{1}' already exists." diff --git a/scripts/imagetransfer.py b/scripts/imagetransfer.py index 5968112..f89e8ba 100755 --- a/scripts/imagetransfer.py +++ b/scripts/imagetransfer.py @@ -126,7 +126,18 @@
def __init__(self, generator, targetSite=None, interwiki=False, keep_name=False, ignore_warning=False): - """Initializer.""" + """Initializer. + + @param generator: the pages to work on + @type generator: iterable + @param targetSite: Site to send image to, default none + @type targetSite: pywikibot.site.APISite + @param interwiki: Look for images in interwiki links, default false + @type interwiki: boolean + @param keep_name: Keep the filename and do not verify description + while replacing, default false + @type keep_name: boolean + """ self.generator = generator self.interwiki = interwiki self.targetSite = targetSite
pywikibot-commits@lists.wikimedia.org