def __init__(self, name, command_root_directory, allow_non_existing_modules=False, load_context=None, logs_dir=None, version_func=None, help_func=None): """Initialize Calliope. Args: name: str, The name of the top level command, used for nice error reporting. command_root_directory: str, The path to the directory containing the main CLI module. allow_non_existing_modules: True to allow extra module directories to not exist, False to raise an exception if a module does not exist. load_context: A function that returns a context dict, or None for a default which always returns {}. logs_dir: str, The path to the root directory to store logs in, or None for no log files. version_func: func, A function to call for a top-level -v and --version flag. If None, no flags will be available. help_func: func([command path]), A function to call for in-depth help messages. It is passed the set of subparsers used (not including the top-level command). After it is called calliope will exit. This function will be called when a top-level 'help' command is run, or when the --help option is added on to any command. Raises: backend.LayoutException: If no command root directory is given. """ self.__name = name self.__command_root_directory = command_root_directory if not self.__command_root_directory: raise backend.LayoutException( 'You must specify a command root directory.') self.__allow_non_existing_modules = allow_non_existing_modules self.__config_hooks = backend.ConfigHooks(load_context=load_context) self.__logs_dir = logs_dir self.__version_func = version_func self.__help_func = help_func self.__pre_run_hooks = [] self.__post_run_hooks = [] self.__top_level_command = None self.__modules = []
def __init__(self, name, command_root_directory, allow_non_existing_modules=False, load_context=None, logs_dir=config.Paths().logs_dir, version_func=None): """Initialize Calliope. Args: name: str, The name of the top level command, used for nice error reporting. command_root_directory: str, The path to the directory containing the main CLI module. allow_non_existing_modules: True to allow extra module directories to not exist, False to raise an exception if a module does not exist. load_context: A function that returns a context dict, or None for a default which always returns {}. logs_dir: str, The path to the root directory to store logs in, or None for no log files. version_func: func, A function to call for a top-level -v and --version flag. If None, no flags will be available. Raises: backend.LayoutException: If no command root directory is given. """ self.__name = name self.__command_root_directory = command_root_directory if not self.__command_root_directory: raise backend.LayoutException( 'You must specify a command root directory.') self.__allow_non_existing_modules = allow_non_existing_modules self.__config_hooks = backend.ConfigHooks(load_context=load_context) self.__logs_dir = logs_dir self.__version_func = version_func self.__pre_run_hooks = [] self.__post_run_hooks = [] self.__modules = [] self.__missing_components = {} self.__release_tracks = {}