From a843016ab52b06030d3cd85889b44564316500f0 Mon Sep 17 00:00:00 2001 From: Yader Velásquez Date: Fri, 11 Feb 2011 00:36:51 +0000 Subject: new fuction for mark calendar --- (limited to 'archivo.py') diff --git a/archivo.py b/archivo.py index b913cfa..12a461a 100644 --- a/archivo.py +++ b/archivo.py @@ -135,23 +135,33 @@ def borrar_dato(indice, indice_lista, path): f.flush() f.close() -def lista_meses(path): +def dict_meses(path, fecha=None): + '''Create if not exists and return a data + dictionary with the months index''' path = path + '/data/lista_dias.pkl' + if fecha is not None: + indice = fecha[:4] + fecha = int(fecha[4:]) - meses = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'ago', 'sep', - 'oct', 'nov', 'dec'] - if not os.path.exists(path): _log.debug('THE FILE LISTA_DIAS DID NOT EXISTS') f = open(path, 'wb') datos = {} - for i in meses: - datos[i] = [] pickle.dump(datos, f) else: - f = open(path, 'rb + wb') + f = open(path, 'rb+wb') datos = pickle.load(f) + + if fecha is not None: + if indice in datos: + datos[indice] = lista_fechas.append(fecha) + else: + lista_fechas = [] + lista_fechas.append(fecha) + datos[indice] = lista_fechas + pickle.dump(datos, f) + f.seek(0) f.flush() f.close() -- cgit v0.9.1