From 27dde6eedc76ae3a660cd86abe7db946c80926ea Mon Sep 17 00:00:00 2001 From: yaderv Date: Sat, 26 Feb 2011 16:38:19 +0000 Subject: fixed string --- (limited to 'archivo.py') diff --git a/archivo.py b/archivo.py index 0ffda53..854bc3a 100644 --- a/archivo.py +++ b/archivo.py @@ -23,6 +23,14 @@ import logging from gettext import gettext as _ _log = logging.getLogger('Log archivo') +def separar_cadena(texto): + nuevo_texto = '' + for i in range(0, len(texto), 50): + texto_temporal = texto[i: i + 50] + '\n' + nuevo_texto = nuevo_texto + texto_temporal + + return nuevo_texto + def indice_entero(cadena): '''Convert a turple's index to an interger number, for be used by others functions''' @@ -86,8 +94,8 @@ def guardar_efemeride(path, file_name): '''import, convert and save a new ephemeris database''' path = path + '/data/efemerides.pkl' di = {} - file = open(file_name, 'r') - lines = file.readlines() + archivo = open(file_name, 'r') + lines = archivo.readlines() for i in range(len(lines)): current_text = lines[i][10 : len(lines[i]) - 2] @@ -98,7 +106,7 @@ def guardar_efemeride(path, file_name): file_new = open(path, 'wb') pickle.dump(di,file_new) file_new.close() - file.close() + archivo.close() def guardar_dato(indice, contenido, categoria, bolean, path): '''save the content in a file, add the content to a dictionary->list''' @@ -113,7 +121,7 @@ def guardar_dato(indice, contenido, categoria, bolean, path): if not indice in dia: dia[indice] = [] - + contenido = separar_cadena(contenido) dia[indice].append([contenido, categoria, prioridad]) f.seek(0) pickle.dump(dia, f) -- cgit v0.9.1