コード例 #1
0
def progress(entries, root):
    resources = {}
    for entry in entries:
        field = entry[0]
        text = entry[1].get()
        if field == 'resource files folder':
            if text:
                resources = preprocessor.main(text)
                number_of_files = len(resources)
            else:
                messagebox.showerror("Error", "No resource path specified")
                return
    local = DoubleVar()
    # defines indeterminate progress bar (used while thread is alive) #
    pb1 = ttk.Progressbar(root,
                          orient='horizontal',
                          variable=local,
                          maximum=number_of_files)

    # defines determinate progress bar (used when thread is dead) #
    pb2 = ttk.Progressbar(root, orient='horizontal', mode='determinate')
    pb2['value'] = 100

    # places and starts progress bar #
    pb1.pack(fill=X, expand=1)

    # starts thread #
    thread = Thread(target=generate_schema, args=(entries, resources))
    thread.start()

    # checks whether thread is alive #
    while thread.is_alive():
        local.set(progressbar.progress)
        root.update()  #_idletasks()
        pass

    # once thread is no longer active, remove pb1 and place the '100%' progress bar #
    pb1.destroy()
    pb2.pack()

    return
コード例 #2
0
    sys.exit("Something went wrong when reading settings file")

model = {}
resource_graph = {}
state_graph = {}
if args['model']:
    print('Loading model...')
    nlp_model = {}
    with open(args['model']) as data_file:
        nlp_model = json.load(data_file)
    model = nlp_model['model']
    resource_graph = nlp_model['resource_graph']
    state_graph = nlp_model['state_graph']
elif args['folder']:
    print('Parsing resources...')
    resources = preprocessor.main(args['folder'])
    if not resources:
        print(
            'No resources found, did you insert the correct resources folder?')
        sys.exit()
    resource_names = nlp.plural_extend(resources)
    print('Processing resources...')
    nlp_model = nlp.resource_analysis(resources, resource_names)
    model = nlp_model['model']
    resource_graph = nlp_model['resource_graph']
    state_graph = nlp_model['state_graph']
    with open('output_files/nlp_model.json', 'w') as outfile:
        json.dump(nlp_model, outfile, indent=4)

print('Generating files...')
graph.draw(resource_graph, state_graph, args['fixgraph'])