Skip to content

Commit 206899a

Browse files
authored
Merge pull request #65 from esm-tools/feature/general.yaml
general.yaml is correctly read and added to the finished yaml
2 parents 3ee746e + 1deed2f commit 206899a

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

esm_parser/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__author__ = """Dirk Barbi"""
44
__email__ = 'dirk.barbi@awi.de'
5-
__version__ = "5.1.7"
5+
__version__ = "5.1.8"
66

77

88
from .yaml_to_dict import yaml_file_to_dict

esm_parser/esm_parser.py

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2643,18 +2643,30 @@ def _config_init(self, user_config):
26432643
user_config["defaults"] = {}
26442644

26452645
default_infos = {}
2646-
for i in os.listdir(DEFAULTS_DIR):
2647-
file_contents = yaml_file_to_dict(DEFAULTS_DIR + "/" + i)
2648-
default_infos.update(file_contents)
26492646

2647+
# get the files in the defaults directory and exclude general.yaml
2648+
yaml_files = os.listdir(DEFAULTS_DIR)
2649+
if 'general.yaml' in yaml_files:
2650+
yaml_files.remove('general.yaml')
2651+
2652+
for yaml_file in yaml_files:
2653+
file_contents = yaml_file_to_dict(DEFAULTS_DIR + "/" + yaml_file)
2654+
default_infos.update(file_contents)
26502655

2656+
# construct the `defaults` section of the configuration
26512657
user_config["defaults"].update(default_infos)
26522658

26532659
computer_file = determine_computer_from_hostname()
26542660
computer_config = yaml_file_to_dict(computer_file)
2661+
2662+
if 'general.yaml' in os.listdir(DEFAULTS_DIR):
2663+
general_config = yaml_file_to_dict(f"{DEFAULTS_DIR}/general.yaml")
2664+
else:
2665+
general_config = {}
2666+
26552667
setup_config = {
26562668
"computer": computer_config,
2657-
"general": {},
2669+
"general": general_config,
26582670
}
26592671
for attachment in CONFIGS_TO_ALWAYS_ATTACH_AND_REMOVE:
26602672
attach_to_config_and_remove(setup_config["computer"], attachment,

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 5.1.7
2+
current_version = 5.1.8
33
commit = True
44
tag = True
55

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@
5454
test_suite='tests',
5555
tests_require=test_requirements,
5656
url='https://gitlab.awi.de/esm_tools/esm_parser',
57-
version="5.1.7",
57+
version="5.1.8",
5858
zip_safe=False,
5959
)

0 commit comments

Comments
 (0)