Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/archivo.py
diff options
context:
space:
mode:
authoryaderv <yajosev@gmail.com>2011-02-24 15:35:17 (GMT)
committer yaderv <yajosev@gmail.com>2011-02-24 15:35:17 (GMT)
commitf18321dbc8cd55d8fc6568d787a07c22d201d003 (patch)
tree349e3b0e20b16a69da916fa9f021e3bfdf3c2d07 /archivo.py
parent8f59d01cb7718c9305a9fd747ff7993ef3918d1b (diff)
code improved
Diffstat (limited to 'archivo.py')
-rw-r--r--archivo.py40
1 files changed, 20 insertions, 20 deletions
diff --git a/archivo.py b/archivo.py
index 1932e0f..0ffda53 100644
--- a/archivo.py
+++ b/archivo.py
@@ -138,39 +138,39 @@ def borrar_dato(indice, indice_lista, path):
else:
return 1
-def dict_meses(path, fecha=None):
+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'
- if fecha is not None:
- indice = fecha[:4]
- fecha = int(fecha[4:])
+
+ indice = fecha[:4]
+ fecha = int(fecha[4:])
- if not os.path.exists(path):
- _log.debug('THE FILE LISTA_DIAS DID NOT EXISTS')
- f = open(path, 'wb')
- datos = {}
-
- else:
+ if os.path.exists(path):
f = open(path, 'rb+wb')
datos = pickle.load(f)
- if fecha is not None:
- if indice in datos:
- if not fecha in datos[indice]:
- datos[indice].append(fecha)
- else:
- pass
- else:
- datos[indice] = []
-
-
+ if not indice in datos:
+ datos[indice] = []
+
+ if opcion:
+ if not fecha in datos[indice]:
+ datos[indice].append(fecha)
+ else:
+ _log.debug('THE FILE LISTA_DIAS DID NOT EXISTS')
+ f = open(path, 'wb')
+ datos = {}
+ datos[indice] = []
+
f.seek(0)
pickle.dump(datos, f)
f.close()
return datos
def borrar_dict_meses(path, fecha):
+ '''delete from the dict the date when the
+ activity stack is empty'''
+
path = path + '/data/lista_dias.pkl'
indice = fecha[:4]
fecha = int(fecha[4:])