Пример #1
0
def main(ls):
    get = True
    while get:
        print("Add to list options: ")
        print("1. Create new food")
        print("2. Import from another list")
        print("3. Go back")
        op = input()

        if op.isdigit():
            if int(op) == 1:
                name = input("New food name: ")
                nights = input("Leftover nights: ")
                time = input("Prep+Cook time: ")
                ingredients = input(
                    "List of ingredients (separate items with \",[SPACE]\"): "
                ).rsplit(", ")
                ls.append(food.Food(name, nights, time, ingredients))
                print(f"{name.title()} added")
            elif int(op) == 2:
                print("Select a list: ")
                count = 1
                lists = []
                for f in os.listdir("../lists"):
                    print(f"{count}. {f.replace('.txt', '').title()}")
                    count += 1
                    lists.append(f)
                listChoice = input()
                if listChoice.isdigit():
                    if int(listChoice) < count:
                        fname = lists[int(listChoice) - 1]
                        file = open("../lists/" + fname, "r")
                        list2 = makeFoodList(file, [])
                        file.close()
                        print(f"{fname.title()} List:")
                        view.main(list2)
                        print("Name of food to import: ")
                        importFood = input()
                        for foo in list2:
                            if foo.getName().capitalize(
                            ) is importFood.capitalize():
                                ls.append(importFood)
                                print(f"{importFood} added")
                        else:
                            print("Invalid input")
                    else:
                        print("Invalid input")
                else:
                    print("Invalid input")
            elif int(op) == 3:
                get = False
            else:
                print("Invalid input")
        else:
            print("Invalid input")
Пример #2
0
def subir_imagen():
    from tkFileDialog import askopenfilename

    filename = askopenfilename(
    )  # show an "Open" dialog box and return the path to the selected file
    bkgnd_draw = pygame.Surface((350, 350))

    img = Image.open(filename)
    img = v.Process_image(img)
    v.main(True, filename)
    """v.view_initialization_from_MV(bkgnd_draw)
Пример #3
0
def subir_imagen():
    from tkFileDialog import askopenfilename


    filename = askopenfilename() # show an "Open" dialog box and return the path to the selected file
    bkgnd_draw = pygame.Surface((350, 350))

    img = Image.open(filename)
    img = v.Process_image(img)
    v.main(True, filename)
    """v.view_initialization_from_MV(bkgnd_draw)
Пример #4
0
def analyze(): 
    sent = request.args.get('sentence')
    annotation = request.args.get('anno')
    preproc = u'% TEXT\n{0}\n% ANNO\n{1}'.format(sent, annotation)
    with codecs.open(os.path.join(TEMP_DIR, current_user.get_id()+'.txt'), 'w', 'utf-8') as f:
        f.write(preproc)
    try: 
        view.main([os.path.join(TEMP_DIR, current_user.get_id()+'.txt')])
        return send_file(os.path.join(TEMP_DIR, current_user.get_id()+'.0.png'), mimetype='image/png')
    except Exception as ex:
        return str(ex), 500 
Пример #5
0
def main():
    '''
    エクセルからデータを読み込みGUIを起動します。
    '''

    # エクセルファイルを開く。
    manager = model.Manager('Python リサイクル市 会計用.xlsx', 'raw', '会計録')

    # 商品情報のシートを取得。
    # qtのmodelが得られる。
    items_model = manager.init_all_item_model()
    items_model = manager.get_all_item_model()

    # カートとして使うためのモデルを作る。
    manager.init_purchased_item_model(0, 1)
    cart_model = manager.get_purchased_item_model()

    # GUIを起動。
    view.main(items_model, cart_model)
Пример #6
0
import view
try:
        view.main()
except:
        print('Invalid List Format')
        view.terminate()
Пример #7
0
def cargar_view():
    v.main(False, 0)
Пример #8
0
        client = model.Session(key_name = session_id)
        client.channel_token = channel_token 
        client.put()
        
        memcache.delete("channel_tokens")
        
        template_params = { 'session_id' : session_id, 'channel_token' : channel_token, 'ipinfo_key' : settings.IPINFO_API_KEY }
        self.response.out.write( view.main.render(template_params) )

class Ping(webapp.RequestHandler):
    def get(self):
        session_id = self.request.get('s', None)
        if not session_id is None:
            client = model.Session.get_by_key_name(session_id)
            if not client is None:
                # updating causes client.last_activity to be set to "now"
                client.put()

application = webapp.WSGIApplication(
                                     [
                                      ('/', Backend)
                                     ,('/ping', Ping)
                                     ],
                                     debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
Пример #9
0
#!/usr/bin/env python
import os
if (os.path.dirname(__file__) != ''):
    os.chdir(os.path.dirname(__file__)) # change working directory to `/source`

import view
view.main() # start the program
Пример #10
0
def show_plot():

    options = [h5_file.get(), "-m", str(y_lim_lower.get()), "-M", str(y_lim_upper.get()), "--alpha",
               str(transparency.get()), "--figext", fig_ext.get(), "--fignum", fig_num.get(), "--coord", coords.get()]

    if mask_file.get() != "":
        options.append("--mask")
        options.append(mask_file.get())

    if unit.get() != "":
        options.append("-u")
        options.append(unit.get())
    if colormap.get() != "":
        options.append("-c")
        options.append(colormap.get())
    if projection.get() != "":
        options.append("--projection")
        options.append(projection.get())
    if lr_flip.get() == 1:
        options.append("--flip-lr")
    if ud_flip.get() == 1:
        options.append("--flip-ud")
    if wrap.get() == 1:
        options.append("--wrap")
    if opposite.get() == 1:
        options.append("--opposite")

    if dem_file.get() != "":
        options.append("--dem")
        options.append(dem_file.get())
    if shading.get() == 0:
        options.append("--dem-noshade")
    if countours.get() == 0:
        options.append("--dem-nocontour")
    if countour_smoothing.get() != "":
        options.append("--contour-smooth")
        options.append(countour_smoothing.get())
    if countour_step.get() != "":
        options.append("--contour-step")
        options.append(countour_step.get())

    if subset_x_from.get() != "" and subset_x_to.get() != "":
        options.append("-x")
        options.append(subset_x_from.get())
        options.append(subset_x_to.get())
    if subset_y_from.get() != "" and subset_y_to.get() != "":
        options.append("-y")
        options.append(subset_y_from.get())
        options.append(subset_y_to.get())
    if subset_lat_from.get() != "" and subset_lat_to.get() != "":
        options.append("-l")
        options.append(subset_lat_from.get())
        options.append(subset_lat_to.get())
    if subset_lon_from.get() != "" and subset_lon_to.get() != "":
        options.append("-L")
        options.append(subset_lon_from.get())
        options.append(subset_lon_to.get())

    '''if ref_x.get() != "" and ref_y.get() != "":
        options.append("--ref-yx")
        options.append(ref_y.get())
        options.append(ref_x.get())
    if ref_lat.get() != "" and ref_lon.get() != "":
        options.append("--ref-lalo")
        options.append(ref_lat.get())
        options.append(ref_lon.get())
    if show_ref == 0:
        options.append("--noreference")
    if ref_color.get() != "":
        options.append("--ref-color")
        options.append(ref_color.get())
    if ref_sym.get() != "":
        options.append("--ref-symbol")
        options.append(ref_sym.get())'''

    ''' "--ref-color", ref_color.get(), "--ref-symbol", ref_sym.get() '''

    if font_size.get() != "":
        options.append("-s")
        options.append(font_size.get())
    if plot_dpi.get() != "":
        options.append("--dpi")
        options.append(plot_dpi.get())
    if row_num.get() != "":
        options.append("--row")
        options.append(row_num.get())
    if col_num.get() != "":
        options.append("--col")
        options.append(col_num.get())
    if axis_show.get() == 0:
        options.append("--noaxis")
    if tick_show.get() == 0:
        options.append("--notick")
    if title_show.get() == 0:
        options.append("--notitle")
    if cbar_show.get() == 0:
        options.append("--nocbar")
    if title_in.get() == 1:
        options.append("--title-in")
    if title.get() != "":
        options.append("--figtitle")
        options.append(title.get())
    if fig_size_width.get() != "" and fig_size_height.get() != "":
        options.append("--figsize")
        options.append(fig_size_height.get())
        options.append(fig_size_width.get())
    if fig_w_space.get() != "":
        options.append("--wspace")
        options.append(fig_w_space.get())
    if fig_h_space.get() != "":
        options.append("--hspace")
        options.append(fig_h_space.get())

    if coastline.get() != 0:
        options.append("--coastline")
    if resolution.get() != "":
        options.append("--resolution")
        options.append(resolution.get())
    if lalo_label.get() != 0:
        options.append("--lalo-label")
    if lalo_step.get() != "":
        options.append("--lalo-step")
        options.append(lalo_step.get())
    if scalebar_distance.get() != "" and scalebar_lat.get() != "" and scalebar_lon.get() != "":
        options.append("--scalebar")
        options.append(scalebar_distance.get())
        options.append(scalebar_lat.get())
        options.append(scalebar_lon.get())
    if show_scalebar.get() == 0:
        options.append("--noscalebar")

    if save.get() != 0:
        options.append("--save")
    if output_file.get() != "":
        options.append("-o")

        location_parts = h5_file.get().split("/")
        location = "/".join(location_parts[1:-1])

        options.append("/" + str(location) + "/" + output_file.get())

    if show_info.get() == 1:
        file_info = info.hdf5_structure_string(h5_file.get())
        show_file_info(file_info)

    #print(options)
    if h5_file.get() != "":
        view.main(options)
    else:
        print("No file selected")
Пример #11
0
	def GET(self, *args, **kwargs):
		return view.main()
Пример #12
0
def callModule(tokList, lineNo):
    #this function will be incharge of analyzing the token list, and calling the relative call_module

    #incase the line is a comment, that is it starts with a hash, no processing needed
    if(tokList[0][0] == '#'):
        return

    #the command to execute will be the first word, hence, look up the commands
    command = tokList[0]

    #if else ladder of the commands
    if command == "get":
        tokListLists = preprocess(tokList, lineNo)

        if tokListLists == -1: #identifier not found
            return -1

        for tokenList in tokListLists:
            status = get.main(tokenList, lineNo)
            if(status == -1):
                return status
    
    
    elif command == "help":
        status = help.main(tokList, lineNo)
        return status


    elif command == "view":
        tokListLists = preprocess(tokList, lineNo)

        if tokListLists == -1: #identifier not found
            return -1

        for tokenList in tokListLists:
            status = view.main(tokenList, lineNo)
            if(status == -1):
                return status


    elif command == "let":
        status = let.main(tokList, lineNo, varTable, listTable)

        #if status is -1, error has occoured, or else, add variable to the table
        if status != -1:
            varTable[status[0]] = status[1]

        return status
    

    elif command == "list":
        status = listCmd.main(tokList, lineNo, varTable, listTable)

        #if status is -1, error has occoured, or else, add list to the table
        if status != -1:
            listTable[status[0]] = status[1]
        
        return status

    elif command == "freevar":
        #this block of code is to remove all the variables that user wants to delete

        varToDelete = tokList[1:]

        #error checking to ensure all the variables do infact exist
        flag=1
        for var in varToDelete:
            if var in varTable:
                continue
            else:
                print("Error on line " + str(lineNo) + " no variable: " + var + " found")
                flag=0

        if(flag==0):
            #if flag is 0, the command is incorrect
            return -1
        
        #now to go about and deleting all the variables from the varTable

        for var in varToDelete:
            del varTable[var]
    
    elif command == "freelist":
        #this block of code is to remove all the lists that the user wants to delete

        listsToDelete = tokList[1:]

        #error checking to ensure all the lists do infact exist
        flag=1
        for list_ in listsToDelete:
            if list_ in listTable:
                continue
            else:
                print("Error on line " + str(lineNo) + " no list: " + list_ + " found")
                flag=0

        if(flag==0):
            #if flag is 0, the command is incorrect
            return -1
        
        #now to go about and deleting all the variables from the varTable

        for list_ in listsToDelete:
            del listTable[list_]
    
    elif command == "mem":
        status = mem.main(tokList, lineNo, varTable, listTable)

        #if an error is there in the command
        if(status == -1):
            return status


    else:
        print("Unkown command: " + command + " on line no: " + str(lineNo))
        return -1
Пример #13
0
def uploadImage():
    filename = askopenfilename()
    pygame.Surface((350, 350))
    img = Image.open(filename)
    view.Process_image(img)
    view.main(True, filename)
Пример #14
0
def loadView():
    view.main(False, 0)
Пример #15
0
def cargar_view():
    v.main(False, 0)
Пример #16
0
def main():
	view.main()