Use KeyValuePairFileLoader intead on getconfig(), since getconfig() is too
authorZac Medico <zmedico@gentoo.org>
Sat, 29 Aug 2009 07:58:22 +0000 (07:58 -0000)
committerZac Medico <zmedico@gentoo.org>
Sat, 29 Aug 2009 07:58:22 +0000 (07:58 -0000)
strict about variable names now.

svn path=/main/trunk/; revision=14169

pym/portage/dispatch_conf.py

index df3134c75f1c38fffba6fae23d837e3911aed16e..49e53c2ee0a77aa2660eda734721f3bb84b19377 100644 (file)
@@ -21,15 +21,19 @@ RCS_MERGE = "rcsmerge -p -r" + RCS_BRANCH + " '%s' > '%s'"
 DIFF3_MERGE = "diff3 -mE '%s' '%s' '%s' > '%s'"
 
 def read_config(mandatory_opts):
-    try:
-        opts = portage.getconfig('/etc/dispatch-conf.conf')
-    except:
-        opts = None
-
+    loader = portage.env.loaders.KeyValuePairFileLoader(
+        '/etc/dispatch-conf.conf', None)
+    opts, errors = loader.load()
     if not opts:
         print >> sys.stderr, _('dispatch-conf: Error reading /etc/dispatch-conf.conf; fatal')
         sys.exit(1)
 
+       # Handle quote removal here, since KeyValuePairFileLoader doesn't do that.
+    quotes = "\"'"
+    for k, v in opts.iteritems():
+        if v[:1] in quotes and v[:1] == v[-1:]:
+            opts[k] = v[1:-1]
+
     for key in mandatory_opts:
         if key not in opts:
             if key == "merge":