comparison pyloader/factory.py @ 50:12de7b1bf303

stub interpolation of wrapper options
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 08 Jun 2011 22:17:43 -0700
parents 43cb882c3b72
children d44f3e6dcffa
comparison
equal deleted inserted replaced
49:43cb882c3b72 50:12de7b1bf303
103 def configuration(cls, iniconfig, **defaults): 103 def configuration(cls, iniconfig, **defaults):
104 """interpret configuration from raw .ini syntax""" 104 """interpret configuration from raw .ini syntax"""
105 config = {} 105 config = {}
106 interpolated = set() 106 interpolated = set()
107 seen = set() 107 seen = set()
108 object_string = '%(object)s'
108 109
109 # create a hash of section names 110 # create a hash of section names
110 names = {} 111 names = {}
111 for section in iniconfig: 112 for section in iniconfig:
112 113
124 # interpret decorators 125 # interpret decorators
125 if ':' in path: 126 if ':' in path:
126 wrapper, _path = path.split(':', 1) 127 wrapper, _path = path.split(':', 1)
127 # TODO: could interpolate wrapper 128 # TODO: could interpolate wrapper
128 if wrapper in names: 129 if wrapper in names:
130
131 # TODO: will be correct for
132 # [foo:bar:%(here)s/objects.py:MyClass]
133 # but not for
134 # [foo:bar:fleem]
135 # in the latter case, just use fleem
136 wrapped_name = section
137
129 if wrapper not in config: 138 if wrapper not in config:
130 wrapper_section = names[wrapper] 139 wrapper_section = names[wrapper]
131 if wrapper_section in seen: 140 if wrapper_section in seen:
132 pass # TODO 141 pass # TODO
133 create_section(wrapper_section, iniconfig[wrapper_section]) 142 create_section(wrapper_section, iniconfig[wrapper_section])
134 wrapper_options = config[wrapper] 143 wrapper_options = config[wrapper].copy()
144
135 # TODO interpolate wrapper_options 145 # TODO interpolate wrapper_options
146 if 'args' in wrapper_options:
147 args = wrapper_options['args'][:]
148 wrapper_options['args'] = args
149 if 'kwargs' in wrapper_options:
150 kwargs = wrapper_options['kwargs'].copy()
151 wrapper_options['kwargs'] = kwargs
136 path = _path 152 path = _path
137 153
138 # make a dict for the section 154 # make a dict for the section
139 path = path % defaults 155 path = path % defaults
140 sect = config[name] = dict(path=path) 156 sect = config[name] = dict(path=path)