Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies = [

[project.optional-dependencies]
xml = ["xmltodict>=0.12.0,<1"]
toml = ["tomlkit>=1,<2"]
dev = [
"build",
"proman-versioning>=0.1.1-beta.4",
Expand Down
11 changes: 6 additions & 5 deletions src/compendium/config_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ def load_config(
self,
config_file: ConfigFile,
update: bool = True,
*args: str,
**kwargs: Any,
# *args: str,
# **kwargs: Any,
) -> Optional[Dict[str, Any]]:
"""Load settings from configuration."""
if os.path.exists(config_file.filepath):
Expand Down Expand Up @@ -216,7 +216,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
@property
def namepaths(self) -> Tuple[str, ...]:
"""Return list of namepaths."""
return tuple([self.get_namepath(x.filepath) for x in self.filepaths])
return tuple(self.get_namepath(x.filepath) for x in self.filepaths)

def get_name(self, filepath: str) -> str:
"""Get name from tree path."""
Expand Down Expand Up @@ -273,13 +273,14 @@ def _prep_filepaths(self) -> None:
def load_config(
self,
config_file: ConfigFile,
update: bool = False,
*args: str,
**kwargs: Any,
) -> Optional[Dict[str, Any]]:
"""Load config."""
# TODO: need to separate chainmap of defaults from namespace config
settings = super().load_config(config_file, update)
settings = super().load_config(
config_file, bool(kwargs.pop('update', False))
)
return self.new_child(
settings, name=self.get_name(config_file.filepath), *args, **kwargs
)
Expand Down
5 changes: 4 additions & 1 deletion src/compendium/filepaths.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

@dataclass
class File:
"""Provider file data."""

path: str
name: str = field(init=False)
extension: Optional[str] = field(init=False)
Expand All @@ -28,7 +30,7 @@ def __post_init__(self) -> None:


@dataclass
class ConfigPaths:
class ConfigPaths: # pylint: disable=too-many-instance-attributes
r"""Load config paths based on priority.

First(lowest) to last(highest):
Expand All @@ -51,6 +53,7 @@ class ConfigPaths:
- <CLI>

"""

name: str
filename: str
filetype: Optional[str] = field(init=False)
Expand Down
8 changes: 6 additions & 2 deletions src/compendium/filetypes/ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import errno
import logging
from configparser import ConfigParser # ExtendedInterpolation
from configparser import ConfigParser, Error # ExtendedInterpolation
from typing import Any, Dict, Tuple

from compendium.filetypes import FiletypesBase
Expand All @@ -30,9 +30,13 @@ def load_config(self, filepath: str) -> Dict[str, Any]:
logging.info('loading INI configuration file')
try:
self.__config_parser.read([filepath], encoding=self.encoding)
except Exception:
except Error:
logging.error('Unable to read file')

# pylint: disable-next=protected-access
data = self.__config_parser._sections # type: ignore

# pylint: disable-next=protected-access
for k, v in self.__config_parser._defaults.items(): # type: ignore
data[k] = v
return data
Expand Down
2 changes: 1 addition & 1 deletion src/compendium/filetypes/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dump_config(self, content: Dict[str, Any], filepath: str) -> None:
content,
file,
indent=2,
sort_keys=False
sort_keys=False,
# , default=self.encoder
)
except IOError as err:
Expand Down
2 changes: 1 addition & 1 deletion src/compendium/filetypes/xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import os
from typing import Any, Dict, Tuple

import xmltodict
import xmltodict # pylint: disable=import-error

from compendium.filetypes import FiletypesBase

Expand Down