コード例 #1
0
def available_times(cal_list,begin_date,end_date,begin_time,end_time):
    '''
    Params:
    This function will take a calendar list of GCal events

    This function will then calculate the free times of both Gcals
    using functions stored in agenda, then return a list of free times
    '''
    app.logger.debug("cal_list: {}".format(cal_list))
    app.logger.debug("begin_date: {}".format(begin_date))
    app.logger.debug("end_date: {}".format(end_date))
    app.logger.debug("begin_time: {}".format(begin_time))
    app.logger.debug("end_time: {}".format(end_time))

    free_lists = []
    result = []
    current_agenda = agenda.Agenda()
    for i in cal_list:
        start = arrow.get(i['start']).replace(tzinfo = tz.gettz('US/Pacific'))
        day = start.date()
        end = arrow.get(i['end']).replace(tzinfo = tz.gettz('US/Pacific'))
        summary = i['summary']

        appt = agenda.Appt(day,start,end,summary)
        current_agenda.append(appt)

    #Merge overlapping events in an agenda
    current_agenda.normalize()

    a = arrow.get(begin_date)
    begin_date_time = arrow.get(begin_time).replace(year=a.year,month=a.month, day=a.day, tzinfo = tz.gettz('US/Pacific'))

    b = arrow.get(end_date)
    end_date_time = arrow.get(begin_time).replace(year=b.year,month=b.month, day=b.day, tzinfo = tz.gettz('US/Pacific'))

    for day in arrow.Arrow.range('day',start=begin_date_time, end=end_date_time):
        this_day = arrow.get(day).replace(tzinfo = tz.gettz('US/Pacific'))
        start = arrow.get(begin_time).replace(year=this_day.year,month=this_day.month,day=this_day.day,tzinfo = tz.gettz('US/Pacific'))
        end = arrow.get(end_time).replace(year=this_day.year,month=this_day.month,day=this_day.day,tzinfo = tz.gettz('US/Pacific'))

        day_freetimes = str(current_agenda.complement(agenda.Appt(this_day, start, end, 'free'))).split('\n')
        free_lists.append(day_freetimes)

    app.logger.debug("free_lists: {}".format(free_lists))
    for q in free_lists:
        for i in q:
            split = i.split('|')
            try:
                result.append({"status": 'free',"day":split[0],"start": split[1],"end":split[2]})
            except IndexError:
                    app.logger.debug("All day event removed."); #All day events display as empty list, since busy all day they are removed

    app.logger.debug("result: {}".format(result))
    return result
コード例 #2
0
    def __init__(self, M, writeRawLog=False, safeMode=False, extraConfig={}):
        self.M = M
        self.writers = {}
        # Update config values with anything we may have
        for k, v in extraConfig.iteritems():
            setattr(self, k, v)

        if hasattr(self, "init_hook"):
            self.init_hook()
        if writeRawLog:
            self.writers['.log.txt'] = writers.TextLog(self.M)
        for extension, writer in self.writer_map.iteritems():
            self.writers[extension] = writer(self.M)
        self.safeMode = safeMode
        self.agenda = agenda.Agenda(self)
コード例 #3
0
    def listar(self):
        agenda_nueva = agenda.Agenda()
        lista_contactos = agenda_nueva.devolver_contactos()
        self.etiqueta2_id = tk.Label(self.raiz, text="ID")
        self.etiqueta2_id.grid(sticky="W", column=0, row=1)

        self.etiqueta2_nombre = tk.Label(self.raiz, text="NOMBRE")
        self.etiqueta2_nombre.grid(sticky="W", column=1, row=1)

        self.etiqueta2_apellido = tk.Label(self.raiz, text="APELLIDO")
        self.etiqueta2_apellido.grid(sticky="W", column=2, row=1)

        self.etiqueta2_telefono = tk.Label(self.raiz, text="TELEFONO")
        self.etiqueta2_telefono.grid(sticky="W", column=3, row=1)

        self.etiqueta2_mail = tk.Label(self.raiz, text="MAIL")
        self.etiqueta2_mail.grid(sticky="W", column=4, row=1)

        self.etiqueta2_direccion = tk.Label(self.raiz, text="DIRECCION")
        self.etiqueta2_direccion.grid(sticky="W", column=5, row=1)

        for x in range(len(lista_contactos)):
            self.etiqueta_id = tk.Label(self.raiz,
                                        text=lista_contactos[x].id_contacto)
            self.etiqueta_id.grid(sticky="W", column=0, row=x + 2)

            self.etiqueta_nombre = tk.Label(self.raiz,
                                            text=lista_contactos[x].nombre)
            self.etiqueta_nombre.grid(sticky="W", column=1, row=x + 2)

            self.etiqueta_apellido = tk.Label(self.raiz,
                                              text=lista_contactos[x].apellido)
            self.etiqueta_apellido.grid(sticky="W", column=2, row=x + 2)

            self.etiqueta_telefono = tk.Label(self.raiz,
                                              text=lista_contactos[x].telefono)
            self.etiqueta_telefono.grid(sticky="W", column=3, row=x + 2)

            self.etiqueta_mail = tk.Label(self.raiz,
                                          text=lista_contactos[x].mail)
            self.etiqueta_mail.grid(sticky="W", column=4, row=x + 2)

            self.etiqueta_direccion = tk.Label(
                self.raiz, text=lista_contactos[x].direccion)
            self.etiqueta_direccion.grid(sticky="W", column=5, row=x + 2)
コード例 #4
0
import agenda

ac = agenda.Agenda('agenda.db')

#O método filtra deve retornar uma lista no qual cada item é um par nome-contato
registro = ac.filtra('m')[1]

print(registro[0], '>>', registro[1])

#O método apaga deve retornar quantos registros foram apagados ao ser realizado
print(ac.apaga('multi'))

#O método todos também deve retornar uma lista no qual cada item é um par nome-contato
for registro in ac.todos():
    print(registro[0], '>>', registro[1])