diff options
author | Rafael Ortiz <rafael@activitycentral.com> | 2011-07-13 20:07:08 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2011-07-13 20:07:08 (GMT) |
commit | e040f7405990c57f6522dc417aa02b6f56ba3226 (patch) | |
tree | 2b377becf13cb9e8566a153ddae3b327eda9307f | |
parent | 4c9afbc70d578b7c3a156e57ac119e431548b69d (diff) |
pep8 fixes
-rw-r--r-- | archivo.py | 48 |
1 files changed, 27 insertions, 21 deletions
@@ -23,6 +23,7 @@ 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), 40): @@ -31,20 +32,21 @@ def separar_cadena(texto): return nuevo_texto + def indice_entero(cadena): '''Convert a turple's index to an interger number, for be used by others functions''' - cadena = cadena.replace('(','') - cadena = cadena.replace(',','') - cadena = cadena.replace(')','') + cadena = cadena.replace('(', '') + cadena = cadena.replace(',', '') + cadena = cadena.replace(')', '') return int(cadena) + def crear_modelo(indice, path): '''create the liststore model for the main block''' path = path + '/data/actividades.pkl' modelo = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING,\ gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_STRING) - if not os.path.exists(path): _log.debug('THE FILE ACTIVIDADES DID NOT EXISTS') archivo = open(path, 'wb') @@ -56,7 +58,6 @@ def crear_modelo(indice, path): archivo = open(path, 'rb') dia = pickle.load(archivo) contar_int = 1 - if indice in dia: if len(dia[indice]): for activ in dia[indice]: @@ -65,7 +66,7 @@ def crear_modelo(indice, path): contar_int += 1 else: modelo.append(['', '', '', None, None, None, None]) - else : + else: modelo.append(['', '', '', None, None, None, None]) archivo.close() @@ -104,6 +105,7 @@ def comprobar_archivo(path, archivo): else: return True + def abrir_archivo(path, archivo): '''open the ephemerides file and return a data dictionary''' if archivo is 'efemeride': @@ -115,6 +117,7 @@ def abrir_archivo(path, archivo): archivo.close() return texto + def guardar_archivo(path, file_name, tipo_archivo): '''import, convert and save a new ephemeris/phrases database''' if tipo_archivo is 1: @@ -126,23 +129,24 @@ def guardar_archivo(path, file_name, tipo_archivo): lines = archivo.readlines() for i in range(len(lines)): if tipo_archivo is 1: - current_text = lines[i][10 : len(lines[i]) - 2] + current_text = lines[i][10: len(lines[i]) - 2] else: - current_text = lines[i][4 : len(lines[i]) - 2] - for j in range(30, len(current_text),30): + current_text = lines[i][4: len(lines[i]) - 2] + for j in range(30, len(current_text), 30): current_text = current_text[:j] + '-\n' + current_text[j:] if tipo_archivo is 1: - current_id = lines[i][0 : 8] + current_id = lines[i][0: 8] else: - current_id = lines[i][0 : 2] + current_id = lines[i][0: 2] di[current_id] = current_text _log.debug(di[current_id]) file_new = open(path, 'wb') - pickle.dump(di,file_new) + pickle.dump(di, file_new) file_new.close() archivo.close() + def guardar_dato(indice, contenido, categoria, entero_cat, bolean, progre, path, indice_lista=False): '''save the content in a file, add the content to a dictionary->list''' color_categoria = ['#6E92FF', '#82FF5F', '#FFE251', '#FF7D7D', '#FFFFFF'] @@ -151,7 +155,7 @@ def guardar_dato(indice, contenido, categoria, entero_cat, bolean, progre, path, indice = str(indice) f = open(path, 'rb+wb') dia = pickle.load(f) - + if bolean: prioridad = gtk.STOCK_ABOUT else: @@ -186,6 +190,7 @@ def guardar_dato(indice, contenido, categoria, entero_cat, bolean, progre, path, pickle.dump(dia, f) f.close() + def borrar_dato(indice, indice_lista, path): '''delete the selected content''' path = path + '/data/actividades.pkl' @@ -198,27 +203,27 @@ def borrar_dato(indice, indice_lista, path): f.seek(0) pickle.dump(dia, f) f.close() - - if len(dia[indice]): #return 1 if the date does not have data - return 0 + + if len(dia[indice]): # return 1 if the date does not have data + return 0 else: - return 1 + return 1 + def dict_meses(path, fecha, opcion=0): '''Create if not exists and return a data dictionary with the months index''' path = path + '/data/lista_dias.pkl' - indice = fecha[:4] fecha = int(fecha[4:]) - + if os.path.exists(path): f = open(path, 'rb+wb') datos = pickle.load(f) - + if not indice in datos: datos[indice] = [] - + if opcion: if not fecha in datos[indice]: datos[indice].append(fecha) @@ -233,6 +238,7 @@ def dict_meses(path, fecha, opcion=0): f.close() return datos + def borrar_dict_meses(path, fecha): '''delete from the dict the date when the activity stack is empty''' |