Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/archivo.py
diff options
context:
space:
mode:
authorYader Velásquez <yajosev@gmail.com>2010-12-28 19:11:21 (GMT)
committer Yader Velásquez <yajosev@gmail.com>2010-12-28 19:11:21 (GMT)
commit94ea0d4c70473a4dc0a0d09664083dab8aafc28f (patch)
tree3a9d5df962f60bb2863359e82615e9351e3e67ef /archivo.py
parentbb127b79b1d21f32143ad6f482b49a19d363d919 (diff)
nueva funcion de importar
Diffstat (limited to 'archivo.py')
-rw-r--r--archivo.py48
1 files changed, 37 insertions, 11 deletions
diff --git a/archivo.py b/archivo.py
index be4b5a4..03af5c0 100644
--- a/archivo.py
+++ b/archivo.py
@@ -66,22 +66,48 @@ def crear_modelo(indice, path):
archivo.close()
return modelo
-def abrir_efemeride(path):
- '''open the ephemeris file and return a data dictionary'''
+def comprobar_efemeride(path):
+ '''test is the ephemeri file exists'''
path = path + '/data/efemerides.pkl'
if not os.path.exists(path):
- _log.debug('THE FILE EFEMERIDES DID NOT EXISTS')
- archivo = open(path, 'wb')
- texto = {}
- pickle.dump(texto, archivo)
- archivo.close()
+ return False
else:
- _log.debug('THE FILE EPHEMERIS EXISTS')
- archivo = open(path, 'rb')
- texto = pickle.load(archivo)
- archivo.close()
+ return True
+
+def abrir_efemeride(path):
+ '''open the ephemeris file and return a data dictionary'''
+ path = path + '/data/efemerides.pkl'
+ #if not os.path.exists(path):
+ # _log.debug('THE FILE EFEMERIDES DID NOT EXISTS')
+ # archivo = open(path, 'wb')
+ # texto = {}
+ # pickle.dump(texto, archivo)
+ # archivo.close()
+ #else:
+ _log.debug('THE FILE EPHEMERIS EXISTS')
+ archivo = open(path, 'rb')
+ texto = pickle.load(archivo)
+ archivo.close()
return texto
+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()
+ for i in range(len(lines)):
+ current_text = lines[i][10 : len(lines[i]) - 2]
+
+ for j in range(30, len(current_text),30):
+ current_text = current_text[:j] + '\n' + current_text[j + 1 :]
+ current_id = lines[i][0 : 8]
+ di[current_id] = current_text
+ file_new = open(path, 'wb')
+ pickle.dump(di,file_new)
+ file_new.close()
+ file.close()
+
def guardar_dato(indice, contenido, categoria, bolean, path):
'''save the content in a file, add the content to a dictionary->list'''
path = path + '/data/actividades.pkl'