Skip to content

jmenu.main

This file contains the logic for executing jmenu from the command line. This file can be imported and exposes the following functions:

* run
* get_version

get_version()

Returns the application build version

version data is pulled by importlib.metadata.version, defaults to 'development build' if it is not somehow present

Returns:

Name Type Description
version str

semantic versioning string

Source code in src/jmenu/main.py
164
165
166
167
168
169
170
171
172
173
174
175
176
177
def get_version() -> str:
    """Returns the application build version

    version data is pulled by importlib.metadata.version,
    defaults to 'development build' if it is not somehow present

    Returns:
        version (str):
            semantic versioning string
    """
    try:
        return version("jmenu")
    except PackageNotFoundError:
        return "development build"

run()

Fetch and print restaurant menus

Returns:

Name Type Description
success bool

returns True if any errors were encountered, returns False otherwise

Source code in src/jmenu/main.py
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
def run():
    """Fetch and print restaurant menus

    Returns:
        success (bool):
            returns True if any errors were encountered,
            returns False otherwise
    """
    try:
        args = _get_args()
        if args.explain:
            _print_explanations(args.lang_code)
            return 0
        start = time.time()
        encountered_error = _print_menu(args)
        print("Process took {:.2f} seconds.".format(time.time() - start))
        return encountered_error
    except KeyboardInterrupt:
        return True