Utente:G4/Script: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
G4 (discussione | contributi)
G4 (discussione | contributi)
Riga 166:
wikipedia.stopme()
 
</source>
===Avanzamento===
Versione evoluta di inseriscitesto.py.
====<tt>Avanzamento.py</tt> v. 1.00====
<source lang="python" line>
import string
import wikipedia
def main():
crlf = "\n{{Avanzamento|"
crd = "%}}"
all = False
cart = "c:/"
file = "testo.txt"
argomenti = wikipedia.handleArgs()
for crrente in argomenti:
if corrente.startswith("-cartella:"):
cart = currentArgument[10:]
if corrente.startswith("-file:"):
file = currentArgument[6:]
if corrente.startswith("-always"):
all = True
nomefile = cart + file
fonte = open(nomefile, 'r')
for line in fonte.readlines():
testo = line.split('<<')
i = len(testo)
if i > 1 :
sito=wikipedia.getSite(code='it',fam='wikibooks')
pl = wikipedia.Page(sito, testo[0])
testo_originale = pl.get()
testo_nuovo = testo_originale + crlf + testo[1] + crd
if (not all):
wikipedia.output(">>>>>" + pl.title() + "<<<<<\n")
wikipedia.output("Si sta tentando di categorizzare\nla pagina come " + testo[1] + "%\n")
choice = wikipedia.inputChoice(u"Categorizzo?", ['Si', 'No', 'Tutti'], ['S', 'N', 'T'], 'N')
else:
choice = 'S'
if choice in ['T', 't']:
all = True
choice = 'S'
if choice in ['S', 's']:
pl.put(testo_nuovo,'[[Wikibooks:Bot|Bot]]: Categorizzo: "' + testo[1] + '%"')
fonte.close()
if __name__ == "__main__":
try:
main()
except:
wikipedia.stopme()
raise
else:
wikipedia.stopme()
</source>