presentation tiramisu
[tiramisu.git] / config.py
index 86b246d..596a580 100644 (file)
--- a/config.py
+++ b/config.py
@@ -19,6 +19,7 @@
 # The original `Config` design model is unproudly borrowed from 
 # the rough gus of pypy: pypy: http://codespeak.net/svn/pypy/dist/pypy/config/
 # the whole pypy projet is under MIT licence
+# ____________________________________________________________
 from error import (HiddenOptionError, ConfigError, NotFoundError, 
                 AmbigousOptionError, ConflictConfigError, NoMatchingOptionFound, 
                             SpecialOwnersError, MandatoryError, MethodCallError, 
@@ -26,29 +27,7 @@ from error import (HiddenOptionError, ConfigError, NotFoundError,
 from option import (OptionDescription, Option, SymLinkOption, group_types, 
                                                           apply_requires, modes)
 import autolib
-# ____________________________________________________________
-# automatic Option object
-special_owners = ['auto', 'fill']
-                  
-def special_owner_factory(name, owner, default=None, 
-                              callback=None, config=None):
-    # auto behavior: carries out a calculation
-    if owner == 'auto':
-        return auto_factory(name, callback, config)
-    # fill behavior: carries out a calculation only if a default value isn't set
-    if owner == 'fill':
-        if default == None:
-            return auto_factory(name, callback, config)
-        else:
-            return default
-
-def auto_factory(name, callback, config):
-    try:
-        return getattr(autolib, callback)(name, config)
-    except AttributeError:
-        raise SpecialOwnersError("callback: {0} not found for "
-                                           "option: {1}".format(callback, name))
-    
+from autolib import special_owners, special_owner_factory
 # ____________________________________________________________
 class Config(object):
     _cfgimpl_hidden = True