From 8f2e50730de78d5650cfdaacb0a519ddc9337c90 Mon Sep 17 00:00:00 2001 From: Karl-Hermann Wieners <karl-hermann.wieners@mpimet.mpg.de> Date: Fri, 28 Jun 2019 17:26:05 +0000 Subject: [PATCH] mkexp: added common update module for 'getconfig', 'editexp', and 'mkexp.bash' --- CHANGES.txt | 1 + mkexp.bash | 7 +++++-- update.py | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index f1c4061..0fa03d1 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -14,6 +14,7 @@ Global * Added 'getconfig' tool to generate clean config files from 'update' scripts * Added 'editexp' tool to edit the config file for a given 'update' script +* Added common update module for 'getconfig', 'editexp', and 'mkexp.bash' * Added 'upexp' tool to run the 'update' script for a given config file Templates diff --git a/mkexp.bash b/mkexp.bash index 5f46d08..f329987 100644 --- a/mkexp.bash +++ b/mkexp.bash @@ -30,12 +30,15 @@ cdexp () { cfg="$1" elif [[ -f update ]] then - eval $(awk '/^cd / {dir=$2; print "dir=" dir ";"}; /^exec / {print "cfg=" $3}' update) + eval $(python -c ' +import update +u = update.Update("update") +print("dir="+u.get_config_dir()+"\ncfg="+u.get_config_file()) + ') else echo 'Oops: invalid number of parameters' >&2 return 1 fi - [[ $cfg != /* ]] && cfg=$dir/$cfg var=${var^^} var=${var%_DIR} vardir=$(builtin cd "$dir" && getexp -k "${var}_DIR" "$cfg") && diff --git a/update.py b/update.py index 39d4e1f..2ecffac 100644 --- a/update.py +++ b/update.py @@ -37,6 +37,9 @@ class Update: update_file.close() + def get_config_dir(self): + return self.config_dir + def get_config_file(self): config_file = self.mkexp_args.config if not os.path.isabs(config_file): -- GitLab