def __init__(self) -> None: self.config_filename = state.State( ).user_config_file.get_config_file_name() self.schemas: Dict[str, Any] = {} for schema_version, schema_path in self.active_schemas.items(): self.schemas[schema_version] = self.load_json_file( self._schema_folder / schema_path)
def create_instance( self) -> cli_custom_commands.CustomClickCommandIterator: with patch( state.__name__ + ".user_configuration_file.UserConfigurationFile.load_yaml_file" ) as m_load: m_load.return_value = self.create_test_config() state.State().load() instance = cli_custom_commands.CustomClickCommandIterator() return instance
def load_custom_commands() -> click.Group: """Create and attach the custom commands to the click group. :returns: The click group, with all custom commands attached. """ state.State().load() for custom_command in cli_custom_commands.CustomClickCommandIterator(): document_custom_commands.add_command(custom_command) return document_custom_commands
def project_root_path(self) -> pathlib.Path: """Return the path to the project root.""" if not self._project_root_path: project_relative_path = state.State().\ user_config.get_project_name() project_absolute_path = self.repo_root_path / project_relative_path self._path_does_not_exist( project_absolute_path, _("ERROR: Project not found: {path}" " (config: {key}, env: {env})").format( path=project_absolute_path, key=yaml_keys.V210_CLI_CONFIG_PROJECT_NAME, env=config.ENV_OVERRIDE_PROJECT_NAME, ), config.EXIT_CODE_PROJECT_NAME_ROOT_NOT_FOUND) self._project_root_path = project_absolute_path return self._project_root_path
def _get_environment_config(self) -> List[TypeRunnerEnvVar]: user_configuration = state.State().user_config return [ TypeRunnerEnvVar( name=config.ENV_OVERRIDE_PROJECT_NAME, value=user_configuration.get_project_name(), always_set=False, ), TypeRunnerEnvVar( name=config.ENV_OVERRIDE_DOCUMENTATION_ROOT, value=user_configuration.get_documentation_root(), always_set=False, ), TypeRunnerEnvVar( name=self.overload_environment_variable, value=" ".join(self.overload), always_set=True, ), ]
def documentation_root_path(self) -> pathlib.Path: """Return the path to the documentation root.""" if not self._documentation_root_path: documentation_relative_path = state.State().\ user_config.get_documentation_root() documentation_absolute_path = (self.repo_root_path / documentation_relative_path) self._path_does_not_exist( documentation_absolute_path, _("ERROR: Documentation not found: {path} " "(config: {key}, env: {env})").format( path=documentation_absolute_path, key=yaml_keys.V210_CLI_CONFIG_DOCS_FOLDER, env=config.ENV_OVERRIDE_DOCUMENTATION_ROOT, ), config.EXIT_CODE_DOCUMENTATION_ROOT_NOT_FOUND) self._documentation_root_path = documentation_absolute_path.absolute( ) return self._documentation_root_path
def __init__(self) -> None: self.user_configuration = state.State().user_config self.configuration_commands = list( self.user_configuration.configuration_command_index.keys() )
def setUp(self) -> None: state.State.clear() state.State().load()
def setUp(self) -> None: state.State.clear() self.mock_user_config = Mock() state.State().user_config = self.mock_user_config