mirror of
https://github.com/arcan1s/ahriman.git
synced 2026-08-20 23:37:26 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
695424fa16 | ||
|
|
255ebe117a |
@@ -164,7 +164,7 @@ class Setup(Handler):
|
|||||||
if args.generate_salt:
|
if args.generate_salt:
|
||||||
configuration.set_option("auth", "salt", User.generate_password(20))
|
configuration.set_option("auth", "salt", User.generate_password(20))
|
||||||
|
|
||||||
include_path = next(path for path in root.include if os.access(path, os.W_OK))
|
include_path = next(path for path in root.getpathlist("settings", "include") if os.access(path, os.W_OK))
|
||||||
(include_path / "00-setup-overrides.ini").unlink(missing_ok=True) # remove old-style configuration
|
(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"
|
target = include_path / f"00-setup-overrides-{repository_id.id}.ini"
|
||||||
with target.open("w", encoding="utf8") as ahriman_configuration:
|
with target.open("w", encoding="utf8") as ahriman_configuration:
|
||||||
|
|||||||
@@ -108,16 +108,6 @@ class Configuration(configparser.RawConfigParser):
|
|||||||
_, repository_id = self.check_loaded()
|
_, repository_id = self.check_loaded()
|
||||||
return repository_id.architecture
|
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
|
@property
|
||||||
def logging_path(self) -> Path:
|
def logging_path(self) -> Path:
|
||||||
"""
|
"""
|
||||||
@@ -332,14 +322,28 @@ class Configuration(configparser.RawConfigParser):
|
|||||||
self.includes = [] # reset state
|
self.includes = [] # reset state
|
||||||
|
|
||||||
try:
|
try:
|
||||||
for path in self.include: # pylint: disable=not-an-iterable
|
# 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")):
|
for include in sorted(path.glob("*.ini")):
|
||||||
if include == self.logging_path:
|
if include == self.logging_path:
|
||||||
continue # we don't want to load logging explicitly
|
continue # we don't want to load logging explicitly
|
||||||
self.read(include)
|
self.read(include)
|
||||||
self.includes.append(include)
|
self.includes.append(include)
|
||||||
except (FileNotFoundError, configparser.NoOptionError, configparser.NoSectionError):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def merge_sections(self, repository_id: RepositoryId) -> None:
|
def merge_sections(self, repository_id: RepositoryId) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -399,6 +403,7 @@ class Configuration(configparser.RawConfigParser):
|
|||||||
# create another instance and copy values from there
|
# create another instance and copy values from there
|
||||||
instance = self.from_path(path, repository_id)
|
instance = self.from_path(path, repository_id)
|
||||||
self.copy_from(instance)
|
self.copy_from(instance)
|
||||||
|
self.includes = instance.includes
|
||||||
|
|
||||||
def set_option(self, section: str, option: str, value: str) -> None:
|
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))
|
write_mock.assert_called_once_with(pytest.helpers.anyvar(int))
|
||||||
remove_mock.assert_called_once_with(
|
remove_mock.assert_called_once_with(
|
||||||
next(
|
next(
|
||||||
path for path in configuration.include) /
|
path for path in configuration.getpathlist("settings", "include")) /
|
||||||
"00-setup-overrides.ini",
|
"00-setup-overrides.ini",
|
||||||
missing_ok=True)
|
missing_ok=True)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user