Genconfig
  • Overview
  • Repository
  • Tickets
  • Statistics
  • Projects

Repository

Split function to load conf

Parent commits : 157c0072ee617450646b9b8f16fa72f3166e9461,
Children commits : f52c82b248164abf51f18cb08b77c5735bccfacb,

By Laurent Defert on 2011-09-18 11:23:04
Split function to load conf

Browse content
Difference with parent commit 157c0072ee617450646b9b8f16fa72f3166e9461
Files added:
genconfig/get_conf.py

Files modified:
genconfig/genconfig
--- 
+++ 
@@ -27,13 +27,12 @@
 from fnmatch import fnmatch
 from optparse import OptionParser
 import re
-from inspect import isclass
 
 from Cheetah import NameMapper
 from Cheetah.Compiler import DEFAULT_COMPILER_SETTINGS
 from Cheetah.Template import Template
 
-from genconfig.config import GenConfig
+from genconfig.get_conf import getConf
 
 USAGE = """
 genconfig generate    [options] <configuration_file> <output_directory> [<output_file1> ...]
@@ -202,40 +201,10 @@
 import sys
 sys.path.append(getcwd())
 
-try:
-    mod = __import__(opt_conf_file)
-except Exception, e:
-    print "Could not read configuration:"
-    raise
-
-# Looking for a GenConfig instance
-for attr_name in dir(mod):
-    if attr_name == 'GenConfig':
-        continue
-    attr = getattr(mod, attr_name)
-    if not isclass(attr):
-        continue
-
-    top_class = True
-    for _attr_name in dir(mod):
-        if _attr_name == attr_name:
-            continue
-        if not isclass(getattr(mod, _attr_name)):
-            continue
-        if not issubclass(attr, getattr(mod, _attr_name)):
-            top_class = False
-            break
-
-    if not top_class:
-        continue
-
-    if issubclass(attr, GenConfig):
-        conf = attr()
-        break
-else:
+conf = getConf(opt_conf_file)
+if conf is None:
     print "Could not find a GenConfig heriting class"
     exit(1)
-
 
 templates = {}
 for p in conf.config_paths:

Generated with KisssPM