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:28] – [Run] 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 17: Line 23:
  
 ===Config=== ===Config===
 +
 +First create a family file.
 +
 +<code>
 +~/.venvs/pywikibot/bin/python pwb.py generate_family_file.py
 +</code>
  
 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> <code>
-~/.venvs/pywikibot/bin/python pwb.py generate_family_file.py+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> </code>
  
 +Next a user configuration is needed.
 <code> <code>
 cp user-config.py.sample user-config.py cp user-config.py.sample user-config.py
Line 30: Line 63:
 </code> </code>
  
 +Eg.
 +<code>
 +mylang = 'en'
 +family = 'MySite'
 +usernames['MySite']['en'] = 'Mybot'
 +</code>
 +
 +Lastly run the login script to enter the password.
  
 <code> <code>
Line 41: 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 47: 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]]