mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-20 15:27:26 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
52d6b0babc | ||
|
|
3f101dafa4 |
@@ -164,7 +164,7 @@ class Setup(Handler):
|
||||
if args.generate_salt:
|
||||
configuration.set_option("auth", "salt", User.generate_password(20))
|
||||
|
||||
include_path = next(path for path in root.getpathlist("settings", "include") if os.access(path, os.W_OK))
|
||||
include_path = next(path for path in root.include if os.access(path, os.W_OK))
|
||||
(include_path / "00-setup-overrides.ini").unlink(missing_ok=True) # remove old-style configuration
|
||||
target = include_path / f"00-setup-overrides-{repository_id.id}.ini"
|
||||
with target.open("w", encoding="utf8") as ahriman_configuration:
|
||||
|
||||
@@ -108,6 +108,16 @@ class Configuration(configparser.RawConfigParser):
|
||||
_, repository_id = self.check_loaded()
|
||||
return repository_id.architecture
|
||||
|
||||
@property
|
||||
def include(self) -> list[Path]:
|
||||
"""
|
||||
get full path to include directory(ies)
|
||||
|
||||
Returns:
|
||||
list[Path]: path to directory with configuration includes
|
||||
"""
|
||||
return self.getpathlist("settings", "include")
|
||||
|
||||
@property
|
||||
def logging_path(self) -> Path:
|
||||
"""
|
||||
@@ -322,28 +332,14 @@ class Configuration(configparser.RawConfigParser):
|
||||
self.includes = [] # reset state
|
||||
|
||||
try:
|
||||
# raw processing to make sure that options are applied correctly
|
||||
include_directories = shlex.split(self.get("settings", "include", raw=True))
|
||||
except (configparser.NoOptionError, configparser.NoSectionError):
|
||||
return
|
||||
|
||||
for directory in include_directories:
|
||||
value = self._interpolation.before_get( # type: ignore[attr-defined]
|
||||
self,
|
||||
"settings",
|
||||
"include",
|
||||
directory,
|
||||
self._unify_values("settings", None), # type: ignore[attr-defined]
|
||||
)
|
||||
path = self._convert_path(value)
|
||||
if not path.is_dir():
|
||||
continue
|
||||
|
||||
for include in sorted(path.glob("*.ini")):
|
||||
if include == self.logging_path:
|
||||
continue # we don't want to load logging explicitly
|
||||
self.read(include)
|
||||
self.includes.append(include)
|
||||
for path in self.include: # pylint: disable=not-an-iterable
|
||||
for include in sorted(path.glob("*.ini")):
|
||||
if include == self.logging_path:
|
||||
continue # we don't want to load logging explicitly
|
||||
self.read(include)
|
||||
self.includes.append(include)
|
||||
except (FileNotFoundError, configparser.NoOptionError, configparser.NoSectionError):
|
||||
pass
|
||||
|
||||
def merge_sections(self, repository_id: RepositoryId) -> None:
|
||||
"""
|
||||
@@ -403,7 +399,6 @@ class Configuration(configparser.RawConfigParser):
|
||||
# create another instance and copy values from there
|
||||
instance = self.from_path(path, repository_id)
|
||||
self.copy_from(instance)
|
||||
self.includes = instance.includes
|
||||
|
||||
def set_option(self, section: str, option: str, value: str) -> None:
|
||||
"""
|
||||
|
||||
@@ -141,7 +141,7 @@ def test_configuration_create_ahriman(args: argparse.Namespace, configuration: C
|
||||
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||
remove_mock.assert_called_once_with(
|
||||
next(
|
||||
path for path in configuration.getpathlist("settings", "include")) /
|
||||
path for path in configuration.include) /
|
||||
"00-setup-overrides.ini",
|
||||
missing_ok=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user