Example #1
0
def parse_parameters(loader, parameters, args):
    def env(func_args):
        if not isinstance(func_args, list):
            func_args = [func_args]
        return os.environ.get(*func_args)

    def func(func_args):
        kwargs = func_args.get('kwargs', {})
        for value in kwargs.values():
            if dsl_functions.parse(value) != value:
                return _RAW
        kwargs['loader'] = loader
        function = module.load_attribute(func_args['name'])
        return function(**kwargs)

    functions = {
        'env': env,
        'arg': lambda func_args: args[func_args],
        'user_config':
        lambda func_args: getattr(loader.user_config, func_args),
        'loader': lambda func_args: getattr(loader, func_args),
        'func': func
    }
    for name, process in functions.items():
        dsl_functions.register(_function(process), name)
    try:
        return dsl_functions.evaluate_functions(parameters, None, None, None,
                                                None)
    finally:
        for name in functions.keys():
            dsl_functions.unregister(name)
Example #2
0
def parse_parameters(loader, parameters, args):

    def env(func_args):
        if not isinstance(func_args, list):
            func_args = [func_args]
        return os.environ.get(*func_args)

    def func(func_args):
        kwargs = func_args.get('kwargs', {})
        for value in kwargs.values():
            if dsl_functions.parse(value) != value:
                return _RAW
        kwargs['loader'] = loader
        function = module.load_attribute(func_args['name'])
        return function(**kwargs)

    functions = {
        'env': env,
        'arg': lambda func_args: args[func_args],
        'user_config': lambda func_args: getattr(loader.user_config,
                                                 func_args),
        'loader': lambda func_args: getattr(loader, func_args),
        'func': func
    }
    for name, process in functions.items():
        dsl_functions.register(_function(process), name)
    try:
        return dsl_functions.evaluate_functions(parameters,
                                                None, None, None, None)
    finally:
        for name in functions.keys():
            dsl_functions.unregister(name)
 def cleanup(self):
     functions.unregister('to_upper')
 def cleanup(self):
     functions.unregister("to_upper")