Beispiel #1
0
def carga():
    root = Tk()
    root.withdraw()
    root.wm_attributes("-topmost", 1)
    filename = askopenfilename(initialdir="/",
                               filetypes=(("Archivo de LFP", "*.lfp"),
                                          ("All Files", "*.*")),
                               title="Busque su archivo.")
    root.update()
    root.destroy()
    archivo = open(filename, 'r')
    while True:
        linea = archivo.readline()  # lee línea
        if not linea:
            break  # Si no hay más se rompe bucle
        list = Automata.AFD(linea)
        x = 1
        listaElementos = []
        listaSolicutudes = []
        while x < len(list):
            if list[x] == 'BUSCAR' or list[x] == 'buscar' or list[
                    x] == 'ordenar' or list[x] == 'ORDENAR':
                break
            else:
                listaElementos.append(list[x])
                x = x + 1
        while x < len(list):
            listaSolicutudes.append(list[x])
            x = x + 1
        dic1 = {
            'nombre': list[0],
            'lista': listaElementos,
            'solicitud': listaSolicutudes
        }
        listaAlpha.append(dic1)
    archivo.close()  # Cierra archivo
    print("Archivo cargado correctamente")