diff options
author | yaderv <yajosev@gmail.com> | 2011-02-26 16:38:19 (GMT) |
---|---|---|
committer | yaderv <yajosev@gmail.com> | 2011-02-26 16:38:19 (GMT) |
commit | 27dde6eedc76ae3a660cd86abe7db946c80926ea (patch) | |
tree | 46018389e72290e866437721ae376d89432212fc /archivo.py | |
parent | f4987b4fa24996a33fbcc6a6f5966816e0cedcd5 (diff) |
fixed string
Diffstat (limited to 'archivo.py')
-rw-r--r-- | archivo.py | 16 |
1 files changed, 12 insertions, 4 deletions
@@ -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) |