Utente:Wisbot/asteroidi.py: differenze tra le versioni
Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica |
Nessun oggetto della modifica |
||
Riga 160:
match = regex.search(text)
if not match:
wikipedia.output(u'\03{lightred}
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À
newtext = regex.sub('|' + campo + ' = ' + argomentoNuovo,text)
return newtext
Riga 178:
match = regex.search(text)
if not match:
wikipedia.output(u'\03{lightred}
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À
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}
return text
Riga 258:
# controlla che la sostituzione sia abbenuta
if n==0:
wikipedia.output(u'\03{lightred}
return text
Riga 268:
if new in text:
wikipedia.output(u'\03{lightyellow}Il testo "%s" era già inserito\03{default}' %new)
else:
wikipedia.output(u'\03{lightred}
return text▼
return newtext
Riga 344 ⟶ 346:
text = self.aggiungi_cat(text,cat)
else:
wikipedia.output(u'\03{lightred}
return text
text = self.campo(text,'categoria',new_template,aggiungi=True,separator=u', ')
Riga 492 ⟶ 494:
return -1
except ValueError:
wikipedia.output(u'ERROR 00 \03{lightred} Non trovo nella lista degli argomenti possibili uno dei due "%s" "%s"\03{default}' %(x,y))
return 0
Riga 499 ⟶ 501:
# remove commented-out stuff etc.
thistxt = wikipedia.removeDisabledParts(thistxt)
# marker for | in wikilink
marker = '@@'
while marker in thistxt:
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}
return []
# Parameters
Riga 511 ⟶ 520:
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 text
def ordinaTemplate(self,text,listaCampi):
Riga 523 ⟶ 539:
for i in range(0,len(listaCampi)):
if not '=' in listaCampi[i]:
wikipedia.output('\03{lightred}ERROR 83: IL CAMPO "%s" NON CONTIENE "=", salto ordinamento\03{default}' %listaCampi[i])
return text
listaCampi[i] = listaCampi[i].split('=')
▲ print listaCampi
listaCampi[i][0] = listaCampi[i][0].strip()
listaCampi[i][1] = listaCampi[i][1].
listaOrdinata = sorted(listaCampi, cmp=self.funzioneOrdine, key=operator.itemgetter(0))
if not listaOrdinata:
wikipedia.output(u'\03{lightred}
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}
return text
Riga 554 ⟶ 572:
text = page.get()
if not page.canBeEdited():
wikipedia.output(u"\03{lightred}
continue
except wikipedia.NoPage:
wikipedia.output(u'\03{lightred}
continue
except wikipedia.IsRedirectPage:
wikipedia.output(u'\03{lightyellow}FATAL
old_text = text
text = self.fixTemplate(text)
if dati[1]!='':
wikipedia.output(u'\03{lightgreen}Nome alternativo: %s' %dati[1])
Riga 614 ⟶ 635:
wikipedia.output(u'Cannot change %s because of blacklist entry %s' % (page.title(), e.url))
except wikipedia.PageNotSaved, error:
wikipedia.output(u'
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):
|