Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paramter handling with metaconfig #126

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
16 changes: 11 additions & 5 deletions modelbaker/iliwrapper/ili2dbconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,14 @@ def __init__(self, other=None):

def append_args(self, args, values, consider_metaconfig=False, force_append=False):

if not force_append and self.metaconfig and self.metaconfig_id and values:
if not force_append and self.metaconfig_id and values:
if self.metaconfig_params_only:
return
if consider_metaconfig and "ch.ehi.ili2db" in self.metaconfig.sections():
if (
consider_metaconfig
and self.metaconfig
and "ch.ehi.ili2db" in self.metaconfig.sections()
):
metaconfig_ili2db_params = self.metaconfig["ch.ehi.ili2db"]
if values[0][2:] in metaconfig_ili2db_params.keys():
# if the value is set in the metaconfig, then we do consider it instead
Expand All @@ -171,7 +175,7 @@ def to_ili2db_args(self):
)

if self.ilimodels:
self.append_args(args, ["--models", self.ilimodels])
self.append_args(args, ["--models", self.ilimodels], force_append=True)

if self.tomlfile:
self.append_args(args, ["--iliMetaAttrs", self.tomlfile])
Expand Down Expand Up @@ -315,12 +319,14 @@ def to_ili2db_args(self, extra_args=[], with_action=True):
self.append_args(args, ["--defaultSrsCode", "{}".format(self.srs_code)])

if self.pre_script:
self.append_args(args, ["--preScript", self.pre_script])
self.append_args(args, ["--preScript", self.pre_script], force_append=True)
elif self.db_ili_version is None or self.db_ili_version > 3:
self.append_args(args, ["--preScript", "NULL"])

if self.post_script:
self.append_args(args, ["--postScript", self.post_script])
self.append_args(
args, ["--postScript", self.post_script], force_append=True
)
elif self.db_ili_version is None or self.db_ili_version > 3:
self.append_args(args, ["--postScript", "NULL"])

Expand Down