graphdoc.data.helper module

graphdoc.data.helper.check_directory_path(directory_path: str | Path) None[source]

Check if the provided path resolves to a valid directory.

Parameters:

directory_path (Union[str, Path]) – The path to check.

Raises:

ValueError – If the path does not resolve to a valid directory.

Returns:

None

Return type:

None

graphdoc.data.helper.check_file_path(file_path: str | Path) None[source]

Check if the provided path resolves to a valid file.

Parameters:

file_path (Union[str, Path]) – The path to check.

Raises:

ValueError – If the path does not resolve to a valid file.

Returns:

None

Return type:

None

graphdoc.data.helper._env_constructor(loader: SafeLoader, node: ScalarNode) str[source]

Custom constructor for environment variables.

Parameters:
  • loader (yaml.SafeLoader) – The YAML loader.

  • node (yaml.nodes.ScalarNode) – The node to construct.

Returns:

The environment variable value.

Return type:

str

Raises:

ValueError – If the environment variable is not set.

graphdoc.data.helper.load_yaml_config(file_path: str | Path, use_env: bool = True) dict[source]

Load a YAML configuration file.

Parameters:
  • file_path (Union[str, Path]) – The path to the YAML file.

  • use_env (bool) – Whether to use environment variables.

Returns:

The YAML configuration.

Return type:

dict

Raises:

ValueError – If the path does not resolve to a valid file or the environment variable is not set.

graphdoc.data.helper.load_yaml_config_redacted(file_path: str | Path, replace_value: str = 'redacted') dict[source]

Load a YAML configuration file with environment variables redacted.

Parameters:
  • file_path (Union[str, Path]) – The path to the YAML file.

  • replace_value (str) – The value to replace the environment variables with.

Returns:

The YAML configuration with env vars replaced by “redacted”.

Return type:

dict

Raises:

ValueError – If the path does not resolve to a valid file.

graphdoc.data.helper.setup_logging(log_level: Literal['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'])[source]

Setup logging for the application.

Parameters:

log_level (Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]) – The log level.