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-03-15 16:23:39 (GMT)
committer yaderv <yajosev@gmail.com>2011-03-15 16:23:39 (GMT)
commit3f2915558d5d60b5dca115876087068a4372683c (patch)
treed5007bf70435e0488148563aaa539a40a65aada9 /archivo.py
parentc3fe565683236c9c0f738af0120c1c589b1c4e2a (diff)
imported phrases
Diffstat (limited to 'archivo.py')
-rw-r--r--archivo.py33
1 files changed, 24 insertions, 9 deletions
diff --git a/archivo.py b/archivo.py
index 23dff84..73e7f13 100644
--- a/archivo.py
+++ b/archivo.py
@@ -71,26 +71,36 @@ def crear_modelo(indice, path):
archivo.close()
return modelo
-def comprobar_efemeride(path):
+def comprobar_archivo(path, archivo):
'''Return true if the ephemeris database exists,
else return false'''
- path = path + '/data/efemerides.pkl'
+ if archivo is 'efemeride':
+ path = path + '/data/efemerides.pkl'
+ elif archivo is 'frase':
+ path = path + '/data/frase.pkl'
+
if not os.path.exists(path):
return False
else:
return True
-def abrir_efemeride(path):
+def abrir_archivo(path, archivo):
'''open the ephemeris file and return a data dictionary'''
- path = path + '/data/efemerides.pkl'
+ if archivo is 'efemeride':
+ path = path + '/data/efemerides.pkl'
+ elif archivo is 'frase':
+ path = path + '/data/frase.pkl'
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'
+def guardar_archivo(path, file_name, archivo):
+ '''import, convert and save a new ephemeris/phrases database'''
+ if archivo is 1:
+ path = path + '/data/efemerides.pkl'
+ elif archivo is 2:
+ path = path + '/data/frase.pkl'
di = {}
archivo = open(file_name, 'r')
lines = archivo.readlines()
@@ -99,8 +109,13 @@ def guardar_efemeride(path, file_name):
for j in range(30, len(current_text),30):
current_text = current_text[:j] + '\n' + current_text[j:]
- current_id = lines[i][0 : 8]
- di[current_id] = current_text
+ if archivo is 1:
+ current_id = lines[i][0 : 8]
+ else:
+ 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)
file_new.close()