You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
from configparser import ConfigParser, ExtendedInterpolation
|
|
import os
|
|
import errno
|
|
|
|
import machlib.menu as mm
|
|
|
|
# default_configuration_file = "~/.config/mach5/config.ini"
|
|
_default_configuration_file = "./etc/config.ini"
|
|
# _default_menu_file = "~/.config/mach5/menu.yml"
|
|
_default_menu_file = "./etc/menu.yml"
|
|
|
|
# -------------------- MAIN --------------------
|
|
|
|
# Parse command line options
|
|
arg_parser = argparse.ArgumentParser(
|
|
description='Our simple chords application')
|
|
arg_parser.add_argument('-c', '--cfg',
|
|
help='Config ini file',
|
|
default=_default_configuration_file)
|
|
arg_parser.add_argument('-m', '--menu',
|
|
help='Menu yaml file',
|
|
default=_default_menu_file)
|
|
|
|
args = arg_parser.parse_args()
|
|
|
|
# Load configuration file
|
|
_configuration = ConfigParser(interpolation=ExtendedInterpolation())
|
|
found = _configuration.read(os.path.expanduser(args.cfg))
|
|
|
|
if (not found):
|
|
print('[ERROR] Config file not found')
|
|
raise FileNotFoundError(errno.ENOENT,
|
|
os.strerror(errno.ENOENT), args.cfg)
|
|
|
|
menu = mm.Menu.from_file(args.menu)
|
|
|
|
print(menu)
|
|
print(menu.get_entries().keys())
|
|
for v in menu.get_entries().values():
|
|
print(f" {v}")
|
|
print(f"Len is {len(menu)}")
|
|
|
|
print ("-"*10)
|
|
for i in menu:
|
|
print(i)
|