Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tools:pywikibot [2025/02/09 07:31] – [Config] darrontools:pywikibot [2025/02/11 02:42] (current) – [Examples] darron
Line 1: Line 1:
- 
 ====Pywikibot==== ====Pywikibot====
  
-Perform all operations inside the pywikibot repository directory once cloned.+Wikimedia automation scripts. 
 + 
 +===Clone===
  
-===Fetch=== 
 <code> <code>
 git clone --recursive https://github.com/wikimedia/pywikibot git clone --recursive https://github.com/wikimedia/pywikibot
 +</code>
 +
 +Perform all future operations inside the pywikibot repository directory.
 +
 +<code>
 cd pywikibot cd pywikibot
 </code> </code>
Line 27: Line 32:
 Enter the URL and name to create a family file for the private site. Enter the URL and name to create a family file for the private site.
 Select no when asked about interwiki links.  Select no when asked about interwiki links. 
 +
 +Eg.
 +<code>
 +from pywikibot import family
 +
 +class Family(family.Family):  # noqa: D101
 +    name = 'MySite'
 +    langs = {
 +        'en': 'www.example.com',
 +    }
 +
 +    def version(self, code):
 +        return "1.4.3"  # The MediaWiki version used.
 +
 +    def scriptpath(self, code):
 +        return {
 +            'en': '/w',
 +        }[code]
 +
 +    def protocol(self, code):
 +        return {
 +            'en': 'https',
 +        }[code]
 +</code>
  
 Next a user configuration is needed. Next a user configuration is needed.
Line 34: Line 63:
 </code> </code>
  
-EG.+Eg.
 <code> <code>
-mylang = 'en-gb'+mylang = 'en'
 family = 'MySite' family = 'MySite'
-usernames['MySite']['en-gb'] = 'Mybot'+usernames['MySite']['en'] = 'Mybot'
 </code> </code>
  
Line 53: Line 82:
 </code> </code>
  
 +<code>
 +source ~/.venvs/pywikibot/bin/activate.csh
 +./pwb.py welcome.py
 +deactivate
 +</code>
 ===Resources==== ===Resources====
 +
 +[[https://github.com/wikimedia/pywikibot|Github]]|
  
 [[https://doc.wikimedia.org/pywikibot/stable/|Documentation]] [[https://doc.wikimedia.org/pywikibot/stable/|Documentation]]
Line 59: Line 95:
 [[https://www.mediawiki.org/wiki/Manual:Pywikibot/Use_on_third-party_wikis|Third party wikis]] [[https://www.mediawiki.org/wiki/Manual:Pywikibot/Use_on_third-party_wikis|Third party wikis]]
  
-[[https://github.com/wikimedia/pywikibot|Github]] +[[https://www.mediawiki.org/wiki/Manual:Pywikibot/Wikidata|Wikidata]]