commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnue] r9835 - trunk/gnue-common/src/base


From: reinhard
Subject: [gnue] r9835 - trunk/gnue-common/src/base
Date: Tue, 27 Nov 2007 03:42:02 -0600 (CST)

Author: reinhard
Date: 2007-11-27 03:42:02 -0600 (Tue, 27 Nov 2007)
New Revision: 9835

Modified:
   trunk/gnue-common/src/base/utils.py
Log:
Added options for conf.d style configuration directories.


Modified: trunk/gnue-common/src/base/utils.py
===================================================================
--- trunk/gnue-common/src/base/utils.py 2007-11-27 08:25:00 UTC (rev 9834)
+++ trunk/gnue-common/src/base/utils.py 2007-11-27 09:42:02 UTC (rev 9835)
@@ -43,31 +43,52 @@
 
     The list contains all existing config files in the following order of
     directories searched:
-        1. system configuration (usually /etc/gnue/*.conf)
-        2. user configuration (~/.gnue/*.conf)
-        3. local configuration (etc/*.conf)
-        4. environment variable location ($GNUE_*)
-        5. fixed system configuration (/etc/gnue/*.conf.fixed)
-    The practical use for 4. is to define configuration entries that cannot be
+        1. system configuration file (usually /etc/gnue/*.conf)
+        2. system configuration directory (usually /etc/gnue/*.d/)
+        3. user configuration (~/.gnue/*.conf)
+        4. local configuration (etc/*.conf)
+        5. environment variable location ($GNUE_*)
+        6. fixed system configuration (/etc/gnue/*.conf.fixed)
+    The practical use for 6. is to define configuration entries that cannot be
     overwritten by normal users.
 
     For example, if name is C{connections}, on a standard install on a POSIX
     system, the file would be searched in:
         1. C{/etc/gnue/connections.conf}
-        2. C{~/.gnue/connections.conf}
-        3. C{etc/connections.conf} (from the current directory)
-        4. the content of the C{GNUE_CONNECTIONS} environment variable
-        5. C{/etc/gnue/connections.conf.fixed}
+        2. C{/etc/gnue/connections.d/*}
+        3. C{~/.gnue/connections.conf}
+        4. C{etc/connections.conf} (from the current directory)
+        5. the content of the C{GNUE_CONNECTIONS} environment variable
+        6. C{/etc/gnue/connections.conf.fixed}
 
     @param name: name of the configuration file without the .conf ending
     @return: list of full path names of configuration files to parse
     """
+
     files = []
+
+    # 1. system configuration file (usually /etc/gnue/*.conf)
     files.append(os.path.join(paths.config, name + '.conf'))
+
+    # 2. system configuration directory (usually /etc/gnue/*.d/)
+    dir = os.path.join(paths.config, name + '.d')
+    if os.path.isdir(dir):
+        indir = os.listdir(dir)
+        indir.sort()
+        files.extend([os.path.join(dir, f) for f in indir])
+
+    # 3. user configuration (~/.gnue/*.conf)
     if os.environ.has_key('HOME'):
         files.append(os.path.join(os.environ['HOME'], name + '.conf'))
+
+    # 4. local configuration (etc/*.conf)
+    files.append(os.path.join('etc', name + '.conf'))
+
+    # 5. environment variable location ($GNUE_*)
     if os.environ.has_key('GNUE_' + name.upper()):
         files.append(os.environ['GNUE_' + name.upper()])
-    files.append(os.path.join('etc', name + '.conf'))
+
+    # 6. fixed system configuration (/etc/gnue/*.conf.fixed)
     files.append(os.path.join(paths.config, name + '.conf.fixed'))
+
     return [f for f in files if os.path.isfile(f)]





reply via email to

[Prev in Thread] Current Thread [Next in Thread]