- def __init__(self, project_dir, config_dir, environ=None):
+ def __init__(self, project_dir: Path, config_dir: Path,
+ environ: Optional[Mapping[str, str]] = None) -> None:
self.environ = environ or os.environ
self.project_dir = project_dir
self.config_dir = config_dir
self.environ = environ or os.environ
self.project_dir = project_dir
self.config_dir = config_dir
""" Set paths to library functions and data.
"""
for key, value in kwargs.items():
setattr(self.lib_dir, key, Path(value).resolve())
""" Set paths to library functions and data.
"""
for key, value in kwargs.items():
setattr(self.lib_dir, key, Path(value).resolve())
""" Return the given configuration parameter as a boolean.
Values of '1', 'yes' and 'true' are accepted as truthy values,
everything else is interpreted as false.
""" Return the given configuration parameter as a boolean.
Values of '1', 'yes' and 'true' are accepted as truthy values,
everything else is interpreted as false.
return getattr(self, name).lower() in ('1', 'yes', 'true')
return getattr(self, name).lower() in ('1', 'yes', 'true')
""" Return the given configuration parameter as a list of strings.
The values are assumed to be given as a comma-sparated list and
will be stripped before returning them. On empty values None
""" Return the given configuration parameter as a list of strings.
The values are assumed to be given as a comma-sparated list and
will be stripped before returning them. On empty values None
""" Return the given configuration parameter as a Path.
If a relative path is configured, then the function converts this
into an absolute path with the project directory as root path.
""" Return the given configuration parameter as a Path.
If a relative path is configured, then the function converts this
into an absolute path with the project directory as root path.
key, val = param.split('=')
val = val.replace('\\', '\\\\').replace("'", "\\'")
if ' ' in val:
key, val = param.split('=')
val = val.replace('\\', '\\\\').replace("'", "\\'")
if ' ' in val:
""" Return the import style file as a path object. Translates the
name of the standard styles automatically into a file in the
config style.
""" Return the import style file as a path object. Translates the
name of the standard styles automatically into a file in the
config style.
- def load_sub_configuration(self, filename, config=None):
+ def load_sub_configuration(self, filename: StrPath,
+ config: Optional[str] = None) -> Any:
""" Load additional configuration from a file. `filename` is the name
of the configuration file. The file is first searched in the
project directory and then in the global settings dirctory.
""" Load additional configuration from a file. `filename` is the name
of the configuration file. The file is first searched in the
project directory and then in the global settings dirctory.
- def find_config_file(self, filename, config=None):
+ def find_config_file(self, filename: StrPath,
+ config: Optional[str] = None) -> Path:
""" Resolve the location of a configuration file given a filename and
an optional configuration option with the file name.
Raises a UsageError when the file cannot be found or is not
a regular file.
"""
if config is not None:
""" Resolve the location of a configuration file given a filename and
an optional configuration option with the file name.
Raises a UsageError when the file cannot be found or is not
a regular file.
"""
if config is not None:
- cfg_filename = getattr(self, config)
- if cfg_filename:
- cfg_filename = Path(cfg_filename)
+ cfg_value = getattr(self, config)
+ if cfg_value:
+ cfg_filename = Path(cfg_value)
""" Load a YAML configuration file. This installs a special handler that
allows to include other YAML files using the '!include' operator.
"""
""" Load a YAML configuration file. This installs a special handler that
allows to include other YAML files using the '!include' operator.
"""
""" Handler for the '!include' operator in YAML files.
When the filename is relative, then the file is first searched in the
""" Handler for the '!include' operator in YAML files.
When the filename is relative, then the file is first searched in the