From 2ea80bc54c5a10983fdb59b210b9db853a008f94 Mon Sep 17 00:00:00 2001 From: Chris Lamb Date: Sat, 31 Oct 2009 13:53:30 +0000 Subject: [PATCH] Tidy daklib.utils.which_conf_file Signed-off-by: Chris Lamb --- daklib/utils.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/daklib/utils.py b/daklib/utils.py index 1fc1d477..3cc40538 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -712,24 +712,23 @@ def where_am_i (): return res[0] def which_conf_file (): - if os.getenv("DAK_CONFIG"): - print(os.getenv("DAK_CONFIG")) - return os.getenv("DAK_CONFIG") - else: - res = socket.gethostbyaddr(socket.gethostname()) - # In case we allow local config files per user, try if one exists - if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"): - homedir = os.getenv("HOME") - confpath = os.path.join(homedir, "/etc/dak.conf") - if os.path.exists(confpath): - apt_pkg.ReadConfigFileISC(Cnf,default_config) - - # We are still in here, so there is no local config file or we do - # not allow local files. Do the normal stuff. - if Cnf.get("Config::" + res[0] + "::DakConfig"): - return Cnf["Config::" + res[0] + "::DakConfig"] - else: - return default_config + if os.getenv('DAK_CONFIG'): + return os.getenv('DAK_CONFIG') + + res = socket.gethostbyaddr(socket.gethostname()) + # In case we allow local config files per user, try if one exists + if Cnf.FindB("Config::" + res[0] + "::AllowLocalConfig"): + homedir = os.getenv("HOME") + confpath = os.path.join(homedir, "/etc/dak.conf") + if os.path.exists(confpath): + apt_pkg.ReadConfigFileISC(Cnf,default_config) + + # We are still in here, so there is no local config file or we do + # not allow local files. Do the normal stuff. + if Cnf.get("Config::" + res[0] + "::DakConfig"): + return Cnf["Config::" + res[0] + "::DakConfig"] + + return default_config def which_apt_conf_file (): res = socket.gethostbyaddr(socket.gethostname()) -- 2.39.2