diff --git a/CHANGES.txt b/CHANGES.txt index f1c406183a2df062a6d7bdc64f3a400a3e57fd1d..0fa03d1ace1e08f23510737ccf15c692acfae226 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 5f46d0895680612f723c53d277ab58c358bd6e22..f329987a42a869259b5dc952dc1472acbb38486a 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 39d4e1ff65bc1f1be13f12149eb6dfaa76f04657..2ecffac5558baac9f3dfc34063e64262d2ae4875 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):