1313from rez .vendor .enum import Enum
1414from rez .vendor import yaml
1515from contextlib import contextmanager
16- from inspect import isfunction
16+ from inspect import isfunction , getargspec
1717from StringIO import StringIO
1818import sys
1919import os
@@ -170,7 +170,7 @@ def load_py(stream, filepath=None):
170170 return result
171171
172172
173- def process_python_objects (value , filepath = None ):
173+ def process_python_objects (data , filepath = None ):
174174
175175 def _process (value ):
176176 if isinstance (value , dict ):
@@ -182,7 +182,17 @@ def _process(value):
182182 if hasattr (value , "_early" ):
183183 # run the function now, and replace with return value
184184 with add_sys_paths (config .package_definition_build_python_paths ):
185- value_ = value ()
185+ func = value
186+
187+ spec = getargspec (func )
188+ args = spec .args or []
189+ if len (args ) not in (0 , 1 ):
190+ raise ResourceError ("@early decorated function must "
191+ "take zero or one args only" )
192+ if args :
193+ value_ = func (data )
194+ else :
195+ value_ = func ()
186196
187197 # process again in case this is a function returning a function
188198 return _process (value_ )
@@ -204,7 +214,7 @@ def _process(value):
204214 else :
205215 return value
206216
207- return _process (value )
217+ return _process (data )
208218
209219
210220def load_yaml (stream , ** kwargs ):
0 commit comments