예제 #1
0
def main():
    """Main entry point for the script"""
    parser = argparse.ArgumentParser(
        prog='PyVegan',
        description='The better way to collect some delicious vegan recipes!',
        usage="""
        PyVegan - Get delicious vegan recipes from the web!
        Usage: pyvegan [-s/--search ingredient_to_search]


        Examples:
        - Get recipes with potato
            $ pyvegan -s batata
        - Get recipes that use more than one ingredient
            $ pyvegan -s "batata e tomate"

        How to get basic options and help? Use -h/--help
        """,
    )
    parser.add_argument('-s',
                        '--search',
                        type=str,
                        help='Get recipes using the given ingredients')

    options = parser.parse_args()

    if options.search:
        param = options.search
    else:
        param = ''

    try:
        browser = Browser()
        browser.search(param)
        content = browser.page_content()
    except requests.ConnectionError:
        print('A connection problem occurred.')
    except requests.Timeout:
        print('A timeout problem occurred.')
    except requests.TooManyRedirects:
        msg = ('The request exceeds the configured'
               ' number of maximum redirections.')
        print(msg)
    except Exception as e:
        print(e)

    if not content:
        return

    recipeManager = RecipeManager(content)
    recipes = recipeManager.recipes

    menu = Menu(recipes)
    menu.build()
    menu.show()
예제 #2
0
    def __init__(self, *args, **kwargs):
        super(RootBox, self).__init__(*args, **kwargs)
        self.chat_client = None
        self.receive_queue = Queue()

        # create the confirm box for quitting
        self.quit_confirm = ConfirmPopup(title='Quit?', confirm_text='Quit')
        self.quit_confirm.bind(on_confirm=self.quit_pushed)
        self.quit_confirm.bind(on_cancel=self.cancel_pushed)

        # there is some sort of instantiation order problem where you can't
        # directly refer to custom classes as children in the kv language, so
        # everywhere were we want custom classes there is a BoxLayout which we
        # will now put the custom classes inside
        self.menu = Menu()
        self.menu.hide_item('Chats')
        self.menu.bind(text=self.menu_action)
        self.ids.menu_container.add_widget(self.menu)

        self.chat_box = ChatBox()
        self.ids.chat_box_container.add_widget(self.chat_box)
        
        # don't add server_list just yet, it has the connection status label in
        # it
        # self.server_list = ServerBox(self)

        # store = JsonStore('storage.json')
        # try:
        #     userid = store.get('account')['userid']
        #     password = store.get('account')['password']
        #     host = store.get('server')['host']
        #     port = store.get('server')['port']
        # except KeyError as msg:
        #     print("test {}".format(msg))
        #     self.ids.connection_label.text = 'No Username Set'
        # else:
        #     # create the chat client and start processing on separate thread
        #     self.chat_client = ChatClient(self, userid, password)
        #     self.chat_client.connect((host, port))
        #     self.chat_client.process(block=False)

        self.chat_client = TMPClient(self, tmp, username)
예제 #3
0
                break


USER_PROFILE = Menu(
    'User profile Menu',
    [
        [
            'Create blank profile', None,
            create_blank_profile
        ],
        [
            'Show current profile', None,
            get_current_profile
        ],
        [
            'Rate a restaurant', None,
            rate_restaurant
        ],
        [
            'Load user profile', None,
            load_user_profile
        ],
        [
            'Save current user profile', None,
            save_user_profile
        ]
    ]
)


CUISINE_MENU = Menu(