r153 - branches/rewrite/src

Nat Budin partial-mirror-devel@lists.alioth.debian.org
Sat, 03 Jul 2004 16:35:23 -0600


Author: natbudin-guest
Date: Sat Jul  3 16:35:23 2004
New Revision: 153

Modified:
   branches/rewrite/src/Config.py
Log:
Added preliminary, hackish support for config section types.


Modified: branches/rewrite/src/Config.py
==============================================================================
--- branches/rewrite/src/Config.py	(original)
+++ branches/rewrite/src/Config.py	Sat Jul  3 16:35:23 2004
@@ -76,21 +76,25 @@
         'debug',
         ]
 
-    allowed_in_backend = [
+    ### HACK.  Split out later to generalize section types better.
+    allowed_in_mirror_backend = [
         'server',
         'architectures',
         'sections',
         'distributions',
         'filter',
-        'filter_@BACKEND@',
         'get_suggests',
         'get_recommends',
         'get_provides',
 	'include_from_task',
 	'exclude_from_task',
+	'resolve_deps_using',
+        ]
+
+    allowed_in_merge_backend = [
+        'filter_@BACKEND@',
 	'backends',
 	'name',
-	'resolve_deps_using',
         ]
 
     def __init__(self, filename):
@@ -114,9 +118,20 @@
 	for section in conf.sections():
             if section == 'GLOBAL': continue
 	    self[section] = {}
+
+            ###HACK.  Split this out later into subclasses.
+            # detect which config type this is
+            if 'backends' in conf.options(section):
+                allowed_in_section = self.allowed_in_merge_backend
+            elif 'server' in conf.options(section):
+                allowed_in_section = self.allowed_in_mirror_backend
+            else:
+                debug("Unknown section type in section [%s]." % (section))
+                raise InvalidSection(section)
+            
 	    for item, value in conf.items(section):
-		if item not in self.allowed_in_backend:
-		    for allowed_key in self.allowed_in_backend:
+		if item not in allowed_in_section:
+		    for allowed_key in allowed_in_section:
 			# check the allowed_in_backend keys with
 			# @VARIABLES@
 			if allowed_key.find('@') != -1: