From 7ba7794a14c1c9525e175cdc7b4dfb8f3ca76ecd Mon Sep 17 00:00:00 2001 From: Henning Kleen Date: Fri, 8 Jul 2022 14:46:52 +0200 Subject: [PATCH] Allow expansion of environment variables in paths --- kibot/config_reader.py | 1 + kibot/out_kibom.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/kibot/config_reader.py b/kibot/config_reader.py index dfb7291a..f3bc4215 100644 --- a/kibot/config_reader.py +++ b/kibot/config_reader.py @@ -357,6 +357,7 @@ class CfgYamlReader(object): config_error("`import` entry without `file` ({})".format(str(entry))) else: config_error("`import` items must be strings or dicts ({})".format(str(entry))) + fn = os.path.expandvars(os.path.expanduser(fn)) if not os.path.isabs(fn): fn = os.path.join(dir, fn) if not os.path.isfile(fn): diff --git a/kibot/out_kibom.py b/kibot/out_kibom.py index 59d98bd3..8b3f69d1 100644 --- a/kibot/out_kibom.py +++ b/kibot/out_kibom.py @@ -378,7 +378,9 @@ class KiBoMOptions(BaseOptions): kibom_command = self.ensure_tool('KiBoM') format = self.format.lower() prj = GS.sch_no_ext - config = os.path.join(GS.sch_dir, self.conf) + config = os.path.expandvars(os.path.expanduser(self.conf)) + if not os.path.isabs(config): + config = os.path.join(GS.sch_dir, config) if self.output: force_output = True output = name