Configuration file routines (config)#
Functions:
|
Get root path of git repo. |
|
Find the config file |
|
Create a configuration file. |
Classes:
|
Configuration handler |
- open_notebook.config.get_git_root_path(cwd: str | Path | None = None) Path | None[source]#
Get root path of git repo.
- open_notebook.config.get_config_files(cwd: str | Path = '.', home: str | Path | None = None, config_name: str = '.open-notebook.toml') dict[str, Path | None][source]#
Find the config file
Order for search is “current directory”, “git root”, “user home”.
- class open_notebook.config.Config(data: Mapping[str, Any] | Sequence[Mapping[str, Any]], default_params: Mapping[str, Any] | None = None) None[source]#
Bases:
objectConfiguration handler
Accepts multiple mappings. Will parse them left to right for matches
Methods:
get(*keys[, default, factory])Get value from config(s)
get_option(key[, passed, section, default, ...])Get option value from either passed in option, or from config file (left to right).
host([section, passed, default])Host option.
port([section, passed, default])Port option.
root([section, passed, default])Root option.
dir_prefix([section, passed, default])Directory prefix option.
file_prefix([section, passed, default])File prefix option.
to_options_dict([section])Convert options to dictionary.
from_paths(paths[, default_params])Create from path(s).
from_strings(strings[, default_params])Create from string(s).
from_config_files([name, cwd, home, ...])Create from config file(s).
- get(*keys: str, default: Any = MISSING, factory: Callable[[], Any] | None = None) Any[source]#
Get value from config(s)
- get_option(key: str, passed: Any = MISSING, section: str | None = None, default: Any = MISSING, factory: Callable[[], Any] | None = None) Any[source]#
Get option value from either passed in option, or from config file (left to right).
Order of checking is:
passed
data[section][key] for data in self.data.
data[key] for data in self.data.
factory
default
- Parameters:
key (
str, optional) – key to look for.passed (
object) – Passed in value. If notutils.MISSING, this will be the returned value.section (
str, optional) – The table section to check. Fall back to top level of any dict.factory (
callable(), optional) – If no value found, return factory().default – Fallback value to return
- host(section: str | None = None, passed: Any = MISSING, default: str | MISSING_TYPE = MISSING) str[source]#
Host option.
- port(section: str | None = None, passed: Any = MISSING, default: str | MISSING_TYPE = MISSING) str[source]#
Port option.
- root(section: str | None = None, passed: Any = MISSING, default: str | MISSING_TYPE = MISSING) Path[source]#
Root option.
- dir_prefix(section: str | None = None, passed: Any = MISSING, default: str | MISSING_TYPE = MISSING) str[source]#
Directory prefix option.
- file_prefix(section: str | None = None, passed: Any = MISSING, default: str | MISSING_TYPE = MISSING) str[source]#
File prefix option.
- to_options_dict(section: str | None = None, **kws: Any) dict[str, Any][source]#
Convert options to dictionary.
- classmethod from_paths(paths: str | Path | Iterable[str | Path], default_params: Mapping[str, Any] | None = None) Self[source]#
Create from path(s).