Utente:Wisbot/asteroidi.py: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Wiso (discussione | contributi)
Nessun oggetto della modifica
m typo da raffreddore
 
(2 versioni intermedie di 2 utenti non mostrate)
Riga 160:
match = regex.search(text)
if not match:
wikipedia.output(u'\03{lightred}ERRERROR 20: IL CAMPO %s DOVEVA ESSERE GIÀ COMPILATO, MA NON LO È\03{default}' %campo)
return text
vecchio = match.group(1)
regexNuovo = re.compile(name2regex(argomento.strip()),re.IGNORECASE)
match2 = regexNuovo.search(vecchio)
if match2:
Riga 170:
else:
argomentoNuovo = argomento + separator + vecchio
wikipedia.output(u'\03{lightyellow}WARNING 10: IL CAMPO %s ERA GIÀ CAMPILATOCOMPILATO. SOSTITUZIONE "%s" -> "%s"' %(campo,vecchio,argomentoNuovo))
newtext = regex.sub('|' + campo + ' = ' + argomentoNuovo,text)
return newtext
Riga 178:
match = regex.search(text)
if not match:
wikipedia.output(u'\03{lightred}ERRERROR 110: IL CAMPO %s DOVEVA ESSERE GIÀ COMPILATO, MA NON LO È\03{default}' %campo)
return text
vecchio = match.group(1)
regexNuovo = re.compile(name2regex(argomento.strip()),re.IGNORECASE)
match2 = regexNuovo.search(vecchio)
if match2:
Riga 188:
else:
argomentoNuovo = argomento
wikipedia.output(u'\03{lightyellow}WARNING 20: IL CAMPO %s ERA GIÀ CAMPILATOCOMPILATO. SOSTITUZIONE "%s" -> "%s"' %(campo,vecchio,argomentoNuovo))
newtext = regex.sub('|' + campo + ' = ' + argomentoNuovo,text)
return newtext
Riga 208:
if valore_vecchio:
wikipedia.output(u'Il campo %s era già compilato. Vecchio: %s' %(campo,valore_vecchio))
if valore_vecchio.lower() != valore.lower():
if aggiungi:
wikipedia.output(u'Aggiungo %s' %valore)
Riga 238:
# controllo che sia stata aggiunta
if n==0:
wikipedia.output(u'\03{lightred}ERRERROR 31: NON RIESCO AD INSERIRE LA CATEGORIA: %s' %cat)
return text
 
Riga 256:
regex = re.compile(u'(}}.+?è.+?)\. ?',re.DOTALL)
(text,n) = regex.subn(u'\\1%s. ' %new,text,1)
# controlla che la sostituzione sia abbenutaavvenuta
if n==0:
wikipedia.output(u'\03{lightred}ERRERROR 40: NON RIESCO AD INSERIRE LA STRINGA %s ALLA FINE DELLA PRIMA FRASE\03{default}' %new)
return text
Riga 268:
if new in text:
wikipedia.output(u'\03{lightyellow}Il testo "%s" era già inserito\03{default}' %new)
return 1text
else:
wikipedia.output(u'\03{lightred}ERRERROR 50 NON RIESCO AD INSERIRE IL TESTO %s\03{default}' %new)
return 0text
return newtext
 
Riga 344 ⟶ 346:
text = self.aggiungi_cat(text,cat)
else:
wikipedia.output(u'\03{lightred}ERRERROR 60: Parametro orbit non valido: %s\03{default}' %orbit)
return text
text = self.campo(text,'categoria',new_template,aggiungi=True,separator=u', ')
Riga 357 ⟶ 359:
return text.replace('Category','Categoria')
 
def funzioneOrdine(self,x,y):
x = x.strip()
y = y.strip()
x = x[0].lower() + x[1:]
y = y[0].lower() + y[1:]
ordine = [
u'tipo',
Riga 482 ⟶ 480:
u'velocità_radiale']
try:
a =return ordine.index(x[0].strip().lower())
b = ordine.index(y)
if a>b:
return 1
elif x==y:
return 0
else:
return -1
except ValueError:
wikipedia.output(u'ERROR 00 \03{lightred} Non trovo unonella deilista duedegli "%s"argomenti possibili "%s"\03{default}' %( x,y))
return 0
 
Riga 499 ⟶ 489:
# remove commented-out stuff etc.
thistxt = wikipedia.removeDisabledParts(thistxt)
 
# marker for | in wikilink
ymarker = y.strip()'@@'
while marker in thistxt:
ifmarker a>b:+= '@'
result = []
count = 0
Rtemplate = re.compile(r'{{([Tt]emplate:)?([Cc]orpo[ _]celeste).*?(\|(?P<params>[^{]+?))?}}',re.DOTALL)
RMarker = re.compile(r'(\[\[.+?)\|(.+?\]\])')
m = Rtemplate.search(thistxt)
if not m:
wikipedia.output('\03{lightred}ERRERROR 70: NON RIESCO A TROVARE IL TEMPLATE\03{default}')
return []
# Parameters
Riga 511 ⟶ 508:
params = []
if paramString:
paramString = RMarker.sub('\\1%s\\2' % marker, paramString)
 
# Parse string
markedParams = paramString.split('|')
for param in markedParams:
param = param.replace(marker,u'|')
params.append(param)
return params
 
def fixTemplate(self,text):
regex = re.compile(u'\|}}',re.DOTALL)
text = regex.sub('}}',text)
return -1text
 
def ordinaTemplate(self,text,listaCampi):
Riga 523 ⟶ 527:
for i in range(0,len(listaCampi)):
printif not '=' in listaCampi[i]:
wikipedia.output('\03{lightred}ERROR 83: IL CAMPO "%s" NON CONTIENE "=", salto ordinamento\03{default}' %listaCampi[i])
else: return text
listaCampi[i] = listaCampi[i].split('=')
print listaCampi
listaCampi[i][0] = listaCampi[i][0].strip()
listaCampi[i][1] = listaCampi[i][1].lstripstrip()
 
listaOrdinata = sorted(listaCampi, cmpkey=self.funzioneOrdine, key=operator.itemgetter(0))
if not listaOrdinata:
wikipedia.output(u'\03{lightred}ERRERROR 80: NON TROVO IL TEMPLATE\03{default}')
templateText = u'{{Corpo celeste\n'
for record in listaOrdinata:
templateText += u'|' + record[0] + u' = ' + record[1] + '\n'
templateText += u'}}'
regex = re.compile(u'{{[Cc]orpo[ _]celeste.*?}}',re.DOTALL)
(text,n) = regex.subn(templateText,text)
if n==0:
wikipedia.output(u'\03{lightred}ERRERROR 81: NON TROVO IL TEMPLATE!\03{default}')
return text
Riga 554 ⟶ 560:
text = page.get()
if not page.canBeEdited():
wikipedia.output(u"\03{lightred}ERRERROR 90 You can't edit page %s\03{default}" % page.aslink())
continue
except wikipedia.NoPage:
wikipedia.output(u'\03{lightred}ERRERROR 120 Page %s not found\03{lightdefault}' % page.aslink())
continue
except wikipedia.IsRedirectPage:
wikipedia.output(u'\03{lightyellow}FATAL ERRERROR 100 Page is redirect.\03{default}')
 
old_text = text
 
btext = ordineself.indexfixTemplate(ytext)
x = x.strip()
if dati[1]!='':
wikipedia.output(u'\03{lightgreen}Nome alternativo: %s' %dati[1])
Riga 614 ⟶ 623:
wikipedia.output(u'Cannot change %s because of blacklist entry %s' % (page.title(), e.url))
except wikipedia.PageNotSaved, error:
wikipedia.output(u'Error\03{lightred}ERROR 10 putting page: %s\03{default' % (error.args,))
except wikipedia.LockedPage:
wikipedia.output(u'Skipping %s (locked page)' % (page.title(),))
else:
wikipedia.output('\03{lightyellow}WARNING 30 Nessuna modifica da fare\03{default}')
 
def filterArg(gen,argomento,valore):