feat(commit): individual packages from config respected
This commit is contained in:
@@ -13,6 +13,11 @@ def _load_config_file(file: str):
|
||||
|
||||
|
||||
def default_config() -> ArchMgrConfig:
|
||||
"""Get the default configuration
|
||||
|
||||
Returns:
|
||||
The default config
|
||||
"""
|
||||
return {
|
||||
"pkgs": {
|
||||
"individual": [],
|
||||
@@ -59,6 +64,14 @@ def default_config() -> ArchMgrConfig:
|
||||
|
||||
|
||||
def load_config(file: str) -> ArchMgrConfig:
|
||||
"""Load the configuration from the specified file path
|
||||
|
||||
Args:
|
||||
file: Path to the file to be loaded
|
||||
|
||||
Returns:
|
||||
The loaded, validated and parsed config
|
||||
"""
|
||||
# Load and validate initial config
|
||||
try:
|
||||
loaded_conf = _load_config_file(file)
|
||||
|
||||
@@ -3,6 +3,16 @@ from config.dtype import ArchMgrConfig
|
||||
|
||||
|
||||
def merge_configs(config: ArchMgrConfig, new_config: ArchMgrConfig) -> ArchMgrConfig:
|
||||
"""Merge two configs, with the new_config taking precedence over the config
|
||||
in the conflicting fields with arrays and dicts merged
|
||||
|
||||
Args:
|
||||
config: Base config
|
||||
new_config: Config to merge into the base config
|
||||
|
||||
Returns:
|
||||
The merged config
|
||||
"""
|
||||
if len(new_config) == 0 or len(config) == 0:
|
||||
return config
|
||||
|
||||
|
||||
+9
-1
@@ -5,7 +5,15 @@ with open("config.schema.json") as file:
|
||||
schema = json.load(file)
|
||||
|
||||
|
||||
def validate(config):
|
||||
def validate(config: dict | list):
|
||||
"""Validate the specified config
|
||||
|
||||
Args:
|
||||
config: The raw configuration
|
||||
|
||||
Returns:
|
||||
True if the config is valid, False otherwise
|
||||
"""
|
||||
try:
|
||||
jsonschema.validate(config, schema)
|
||||
except jsonschema.SchemaError:
|
||||
|
||||
Reference in New Issue
Block a user