[Piuparts-commits] [SCM] piatti.debian.org configuration files branch, piatti, updated. bd576b4d2a7b962aad4245414b3a858dec5e52c6
Andreas Beckmann
debian at abeckmann.de
Fri Dec 2 13:16:00 UTC 2011
The following commit has been merged in the piatti branch:
commit 832d407e934f4fadef0c16877b5b9a2113f55e85
Author: Andreas Beckmann <debian at abeckmann.de>
Date: Wed Nov 30 14:59:13 2011 +0100
generic config file parsing
a generic method to get values from the config file
Signed-off-by: Andreas Beckmann <debian at abeckmann.de>
diff --git a/home/piupartsm/bin/report_newly_bugged_packages b/home/piupartsm/bin/report_newly_bugged_packages
index 221a5fe..b8f5d9a 100755
--- a/home/piupartsm/bin/report_newly_bugged_packages
+++ b/home/piupartsm/bin/report_newly_bugged_packages
@@ -18,21 +18,28 @@
PIUPARTS_CONF=${PIUPARTS_CONF:-/etc/piuparts/piuparts.conf}
+[ -f "$PIUPARTS_CONF" ] || exit 0
+# usage: get_config_value VARIABLE section key [default]
get_config_value()
{
- local key value
- key="$1"
- value="$(sed -rn -e "/^$key\s*=/s/^$key\s*=\s*//p" "$PIUPARTS_CONF")"
+ local section key value
+ test -n "$1" && test "$1" = "$(echo "$1" | tr -c -d '[:alnum:]_')" || exit 1
+ section="$2"
+ key="$3"
+ value="$(sed -rn '\#^\['"$section"'\]#,/^\[/ {/^'"$key"'\s*=/ {s/^'"$key"'\s*=\s*//; s/\s*$//; p}}' "$PIUPARTS_CONF")"
+ test -n "$value" || value="$4"
if [ -z "$value" ]; then
- echo "'$key' not set in $PIUPARTS_CONF, exiting."
+ echo "'$key' not set in section [$section] of $PIUPARTS_CONF, exiting." >&2
exit 1
fi
- echo "$value"
+ eval "$1"='"$value"'
}
-MASTER=$(get_config_value master-directory)
-SECTIONS=$(get_config_value sections)
+get_config_value MASTER global master-directory
+get_config_value SECTIONS global sections
+get_config_value PIUPARTS_PREFIX global prefix /org/piuparts.debian.org
+
export PYTHONPATH=/org/piuparts.debian.org/lib/python2.6/dist-packages:/org/piuparts.debian.org/lib/python2.7/dist-packages
--
piatti.debian.org configuration files
More information about the Piuparts-commits
mailing list