-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadr.py
53 lines (42 loc) · 1.35 KB
/
adr.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Script de mise à jour de statut de relecteur
# Auteur: Orikrin
# Adapté depuis un script de Linedwell
# Distribué sous licence GNU GPLv3
# Distributed under the terms of the GNU GPLv3 license
# http://www.gnu.org/licenses/gpl.html
import sys
sys.path.insert(1, '..') #ajoute au PYTHONPATH le répertoire parent
import mylogging
import pywikibot
# Déclarations
site = pywikibot.Site('fr','wikipedia')
statuts = ['libre','occupe','pause']
title = u'Utilisateur:Orikrin1998/AdR'
#Exécution
def main(args):
if len(args) > 1: #argv[0] = nom du script
stat = args[1]
if stat in statuts:
if stat == "occupe":
stat = u"occupé"
page = pywikibot.Page(site,title)
pageTemp = stat
summary = u"Mise à jour : " + stat
if page.get() == pageTemp:
print u"Aucune mise à jour nécessaire."
else:
page.text = pageTemp
page.save(summary)
print u"Action effectuée."
else:
print u"Statut '%s' inexistant\nStatuts disponibles : %s" %(stat,str(statuts))
else:
print "usage: python " + args[0] + " <statut>"
sys.exit(2)
if __name__ == "__main__":
try:
main(sys.argv)
finally:
pywikibot.stopme()