Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/archivo.py
blob: 39ccf8e13710783d84e1089608918b5d153391dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding: utf-8 -*-
#
#Copyright (C) 2010, Yader Velasquez
#Copyright (C) 2010, Marcelo Gutierrez
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gtk
import pickle
import gobject
from gettext import gettext as _

def crear_modelo(indice):
    '''create a define liststore model'''
    archivo = open('files/actividades.pkl', 'rb')
    dia = pickle.load(archivo)
    contar = 1
    modelo = gtk.ListStore(gobject.TYPE_INT, gobject.TYPE_STRING)
    #esto cambiara de acuerdo al proceso de automatizacion
    if dia.has_key(indice): 
        for activ in dia[indice]:
            modelo.append([contar, activ]) 
            contar += 1
    else :
        vacio = (_('no hay actividades para el día de hoy'))
        modelo.append([0,vacio])
    archivo.close()
    return modelo

def abrir_efemeride():
    '''open the ephemeris file and return a dictionary'''
    archivo = open('files/efemerides.pkl', 'rb')
    texto = pickle.load(archivo)
    return texto

def guardar_dato(indice, contenido):
    '''add new content to a list in a dictionary'''
    indice = str(indice)
    f = open('files/actividades.pkl', 'rb+wb')
    dia = pickle.load(f)
    dia[indice].append(contenido)
    pickle.dump(dia, f)
    #f.flush()
    f.close()