restruct: needed paths get extra check
This commit is contained in:
parent
c3bf36bf52
commit
ba4624d843
1 changed files with 22 additions and 2 deletions
|
|
@ -11,6 +11,9 @@ from configparser import ConfigParser
|
||||||
from typing import Any
|
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:
|
def has_valid_times(result: pd.Series) -> bool:
|
||||||
"""
|
"""
|
||||||
Check, whether the result at hand has time-stamps that are sensible:
|
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.")
|
raise ValueError("One of the options in the 'core' section ('version', 'tracker', 'cached') is missing.")
|
||||||
|
|
||||||
if config.has_section('paths'):
|
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]
|
has_path_opts = [config.has_option('paths', opt) for opt in path_opts]
|
||||||
if not all(has_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.")
|
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]
|
has_paths = [os.path.exists(path / config.get('paths', opt)) for opt in path_opts]
|
||||||
if not all(has_paths):
|
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:
|
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✅")
|
print("Path and config-file exist:\t✅")
|
||||||
check_config_validity(path)
|
check_config_validity(path)
|
||||||
print("Configuration is valid:\t✅")
|
print("Configuration is valid:\t✅")
|
||||||
|
check_paths(path)
|
||||||
|
print("Needed paths exist:\t✅")
|
||||||
check_db_integrity(path)
|
check_db_integrity(path)
|
||||||
print("DB:\t✅")
|
print("DB:\t✅")
|
||||||
check_db_file_links(path)
|
check_db_file_links(path)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue