feat/minteg #39

Merged
jkuhl merged 6 commits from feat/minteg into develop 2026-05-06 09:37:36 +02:00
Showing only changes of commit ba4624d843 - Show all commits

restruct: needed paths get extra check

Justus Kuhlmann 2026-05-05 17:20:20 +02:00
Signed by: jkuhl
GPG key ID: 00ED992DD79B85A6

View file

@ -11,6 +11,9 @@ from configparser import ConfigParser
from typing import Any
path_opts = ['db', 'projects_path', 'archive_path', 'toml_imports_path', 'import_scripts_path']
def has_valid_times(result: pd.Series) -> bool:
"""
Check, whether the result at hand has time-stamps that are sensible:
@ -178,14 +181,29 @@ def check_config_validity(path: Path) -> None:
raise ValueError("One of the options in the 'core' section ('version', 'tracker', 'cached') is missing.")
if config.has_section('paths'):
path_opts = ['db', 'projects_path', 'archive_path', 'toml_imports_path', 'import_scripts_path']
has_path_opts = [config.has_option('paths', opt) for opt in path_opts]
if not all(has_path_opts):
raise ValueError("One of the options in the 'path' section ('db', 'projects_path', 'archive_path', 'toml_imports_path', 'import_scripts_path') is missing.")
def check_paths(path: Path) -> None:
"""
Check whether all paths demanded by the 'paths' section of the configuration-file exist.
Parameters
----------
path: Path
Path to the backlog-library to check.
"""
config = ConfigParser()
config_path = path / CONFIG_FILENAME
if os.path.exists(config_path):
config.read(config_path)
else:
raise FileNotFoundError("Configuration file not found.")
has_paths = [os.path.exists(path / config.get('paths', opt)) for opt in path_opts]
if not all(has_paths):
raise FileNotFoundError("one of the paths needed by the configuration file is not present.")
raise FileNotFoundError("One of the paths specified in the configuration file is not present.")
def full_integrity_check(path: Path) -> None:
@ -201,6 +219,8 @@ def full_integrity_check(path: Path) -> None:
print("Path and config-file exist:\t")
check_config_validity(path)
print("Configuration is valid:\t")
check_paths(path)
print("Needed paths exist:\t")
check_db_integrity(path)
print("DB:\t")
check_db_file_links(path)