mikrokosmos/objects.py
def resolve_value(value, args, kwargs, ctx):
    """Resolve an attribute value spec, return a lambda to call for the value"""

    try:
        _ = iter(value)
    except TypeError:
        return lambda self, value=value: value

    if 'self.' in value:
        _, att = value.split('.', 1)
        return lambda self, att=att: getattr(self, att)

    elif 'scenario.' in value:
        _, key = value.split('.', 1)
        return lambda self, key=key, ctx=ctx: ctx.scenario[key]

    elif 'faker' in value:
        try:
            provider = kwargs.pop('provider')
        except KeyError:
            _, provider = value.split('.', 1)
        return (
            lambda self, provider=provider, args=args, kwargs=kwargs, ctx=ctx:
                ctx.faker.format(provider, *args, **kwargs)
        )

    elif 'choice' in value:
        return lambda self, args=args: random.choice(args)

    return lambda self, value=value: value
Resolve an attribute value spec, return a lambda to call for the value
Resolve an attribute value spec, return a lambda to call for the value
Resolve an attribute value spec return a lambda to call for the value
def resolve_value(value, args, kwargs, ctx):
    try:
        _ = iter(value)
    except TypeError:
        return lambda self, value=value: value
    if 'self.' in value:
        _, att = value.split('.', 1)
        return lambda self, att=att: getattr(self, att)
    elif 'scenario.' in value:
        _, key = value.split('.', 1)
        return lambda self, key=key, ctx=ctx: ctx.scenario[key]
    elif 'faker' in value:
        try:
            provider = kwargs.pop('provider')
        except KeyError:
            _, provider = value.split('.', 1)
        return (
            lambda self, provider=provider, args=args, kwargs=kwargs, ctx=ctx:
                ctx.faker.format(provider, *args, **kwargs)
        )
    elif 'choice' in value:
        return lambda self, args=args: random.choice(args)
    return lambda self, value=value: value
def resolve_value ( value , args , kwargs , ctx ) : try : _ = iter ( value ) except TypeError : return lambda self , value = value : value if 'self.' in value : _ , att = value . split ( '.' , 1 ) return lambda self , att = att : getattr ( self , att ) elif 'scenario.' in value : _ , key = value . split ( '.' , 1 ) return lambda self , key = key , ctx = ctx : ctx . scenario [ key ] elif 'faker' in value : try : provider = kwargs . pop ( 'provider' ) except KeyError : _ , provider = value . split ( '.' , 1 ) return ( lambda self , provider = provider , args = args , kwargs = kwargs , ctx = ctx : ctx . faker . format ( provider , * args , ** kwargs ) ) elif 'choice' in value : return lambda self , args = args : random . choice ( args ) return lambda self , value = value : value
Resolve an attribute value spec, return a lambda to call for the value
Resolve an attribute value spec return a lambda to call for the value
"""Resolve an attribute value spec, return a lambda to call for the value"""
value
args
kwargs
ctx