Hello,

So, I wanted to have a sorted list of contributors for some page, and I thought that Pywikibot would be a quick way to achieve that without too much pain. And indeed, it was even a pleasure to do it.

Attached is a copy of what I wrote. It's really minimalist, but it does the job.

Now, I'm happy with the service it provides for me, and thought maybe it could be of some use to someone else. It's really a basic use of the library, so I'm unsure it is worth to propose to add it in the repository. Tell me what is your opinion. I don't mean necessarily to include it /as is/ of course, changes following feedback would be expected. But given the triviality of the script, would it be of interest to add it in the list of scripts packaged in the repository?

Cheers


Note to myself if that proves of any interest, some relevant resources are:

 * https://www.mediawiki.org/wiki/Manual:Pywikibot/Development/Guidelines
   <https://www.mediawiki.org/wiki/Manual:Pywikibot/Development/Guidelines>
 * https://www.mediawiki.org/wiki/Manual:Pywikibot/Development#Development
   <https://www.mediawiki.org/wiki/Manual:Pywikibot/Development#Development>
 * https://www.mediawiki.org/wiki/Gerrit/Tutorial/tl;dr
   <https://www.mediawiki.org/wiki/Gerrit/Tutorial/tl;dr>
 * https://www.mediawiki.org/wiki/Gerrit/git-review
   <https://www.mediawiki.org/wiki/Gerrit/git-review>

#!/usr/bin/python
r"""
List contributors of a page
"""
import pywikibot
import argparse

def credit(page):
    site = pywikibot.Site()
    work = pywikibot.Page(site, page)
    try:
        return '\n'.join(sorted(set([log.user for log in work.revisions()])))
    except pywikibot.exceptions.NoPageError as ado:
        return f"""Page "{page}" doesn't exist on the wiki {site}."""

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('title', type=str, help='The name of the page for which credits is asked.')
    fad = parser.parse_args()
    print(credit(fad.title))
_______________________________________________
pywikibot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to