Utilizador:Giro720/Scripts: diferenças entre revisões
Conteúdo apagado Conteúdo adicionado
m Foram revertidas as edições de 189.25.188.176 (disc) para a última versão por Bencmq |
|||
Linha 10:
texto = texto.replace("\n-", "\n— ")
while texto.find(" ")
print "Removendo espaços em branco."
texto = texto.replace(" ", " ")
while texto.find(" ")
print "Removendo tabs."
texto = texto.replace(" ", "")
while texto.find("\n\n \n")
print "Removendo linhas em branco."
texto = texto.replace("\n\n \n", "\n\n")
while texto.find("\n\n\n")
print "Removendo linhas vazias"
texto = texto.replace("\n\n\n", "\n\n")
while texto.find("\n ")
print "Removendo espaços em branco."
texto = texto.replace("\n ", "\n")
Linha 71:
texto = texto.replace(":'''''' -", "")
while texto.find(" ")
print "Removendo tabs."
texto = texto.replace(" ", "")
while texto.find(" ")
print "Removendo espaços em branco."
texto = texto.replace(" ", " ")
while texto.find("\n\n \n")
print "Removendo linhas em branco."
texto = texto.replace("\n\n \n", "\n\n")
while texto.find("\n\n\n")
print "Removendo linhas vazias"
texto = texto.replace("\n\n\n", "\n\n")
while texto.find("\n ")
print "Removendo espaços em branco."
texto = texto.replace("\n ", "\n")
while texto.find(" \n")
print "Removendo espaços em branco."
texto = texto.replace(" \n", "\n")
Linha 111:
"""
def num_romano(num_inteiro):
centena = ((num_inteiro/100)%10)*100
dezena = ((num_inteiro/10)%10)*10
unidade = ((num_inteiro/1)%10
cap_romano=""
if centena == 100:
Linha 189:
for i in range(len(texto)):
if i > 0 and i < len(texto) - 1
if texto[i-1].strip() == "" and texto[i].strip() != "" and texto[i+1].strip() != "" and not control:
entrada.write("<poem>\n")
Linha 216:
entrada.close()
</source>
==capitalizador_simples.py==
<source lang="python">
Linha 239 ⟶ 238:
i = 0
while i < len(texto)
frase = texto[i]
if frase[0] == "@":
cap = 1
entrada.write(frase)
i += 1
elif frase.strip() == num_romano(cap) or frase.strip() == str(cap):
entrada.write("*"+num_romano(cap)+"\n")
cap += 1
i += 1
else:
entrada.write(frase)
i += 1
entrada.close()
Linha 290 ⟶ 289:
titulo_div = unicode(titulo_div_utf, 'utf-8').encode('latin-1')
titulo_div_secao_utf = titulo_div_utf + ":"
div += 1
lista.write("==%s==\n" % titulo_div )
cap = 0
continue
elif frase[0] == '*':
cap += 1
capitulo_utf = frase[1:len(frase)
capitulo = unicode(capitulo_utf, 'utf-8').encode('latin-1')
if div:
Linha 327 ⟶ 326:
obra_utf, autor_utf,
titulo_div_utf + ",", capitulo_utf,
obra_utf, num_romano(div), num_romano(cap+1), titulo_div_secao_utf, num_romano(cap
notas_utf) )
else:
Linha 416 ⟶ 415:
"|posterior=[[%s/%s|CapÃtulo %s]]\n"
"|notas=%s\n}}\n" % (
obra_utf, num_romano(cap
obra_utf, autor_utf,
capitulo_utf,
Linha 461 ⟶ 460:
frase = unicode(texto[i], 'latin-1').encode('utf-8')
if frase[0] == '@':
div_lista[0] += 1
div_lista += [frase[1:len(frase)].strip()]
if div_lista[0] > 1:
fim = i
gera_cabecalho(inicio, fim, div_lista[0]
inicio = fim
cap_anterior = cap_atual
Linha 472 ⟶ 471:
cap_atual += 1
if div_lista[0]:
gera_cabecalho(inicio, len(texto), div_lista[0]
else:
gera_cabecalho(inicio, len(texto), div_lista[0]
lista.write("\n[[Categoria: ]]\n"
Linha 502 ⟶ 501:
for i in range(7, len(texto)):
frase = texto[i]
if frase[
saida.write("%s" % unicode(frase, 'latin-1').encode('utf-8') )
for i in range(7, len(texto)
frase = texto[i]
if frase[0] == '*':
Linha 882 ⟶ 881:
import os
inicio = 3
fim = 151
i=inicio
Linha 897 ⟶ 896:
cmd = "del \"%s.djvu\"" % (i)
os.popen( cmd )
i=i+1
print "Pronto!"
|