Beispiel #1
0
def fake_tag_str(formatter, *args, **kwargs):
    """
    call a faker format
    uses:

        {% fakestr "formatterName" *values **kwargs %}
    """
    if formatter == 'dateTimeThisCentury':
        print(args, kwargs)
    return DjangoFaker.get_generator().format(formatter, *args, **kwargs)
Beispiel #2
0
def do_or_fake_filter(value, formatter):
    """
    call a faker if value is None
    uses:

        {{ myint|or_fake:'randomInt' }}

    """
    if not value:
        value = DjangoFaker.get_generator().format(formatter)
    return value
Beispiel #3
0
def do_fake_filter(formatter, arg=None):
    """
    call a faker format
    uses:

        {{ 'randomElement'|fake:mylist }}
        {% if 'boolean'|fake:30 %} .. {% endif %}
        {% for word in 'words'|fake:times %}{{ word }}\n{% endfor %}

    """
    args = []
    if not arg is None: args.append(arg)
    return DjangoFaker.get_generator().format(formatter, *args)
Beispiel #4
0
def do_fake(formatter, *args, **kwargs):
    """
        call a faker format
        uses:

            {% fake "formatterName" *args **kwargs as myvar %}
            {{ myvar }}

        or:
            {% fake 'name' %}

        """
    return DjangoFaker.get_generator().format(formatter, *args, **kwargs)