

def guessFormat(self, field):
    generator = self.generator
    if isinstance(field, BooleanField):
        return (lambda x: generator.boolean())
    if isinstance(field, NullBooleanField):
        return (lambda x: generator.nullBoolean())
    if isinstance(field, DecimalField):
        return (lambda x: generator.pydecimal(rightDigits=field.decimal_places))
    if isinstance(field, SmallIntegerField):
        return (lambda x: generator.randomInt(0, 65535))
    if isinstance(field, IntegerField):
        return (lambda x: generator.randomInt(0, 4294967295))
    if isinstance(field, BigIntegerField):
        return (lambda x: generator.randomInt(0, 18446744073709551615))
    if isinstance(field, FloatField):
        return (lambda x: generator.pyfloat())
    if isinstance(field, CharField):
        if field.choices:
            return (lambda x: generator.randomElement(field.choices)[0])
        return (lambda x: (generator.text(field.max_length) if (field.max_length >= 5) else generator.word()))
    if isinstance(field, TextField):
        return (lambda x: generator.text())
    if isinstance(field, DateTimeField):
        return (lambda x: generator.dateTime())
    if isinstance(field, DateField):
        return (lambda x: generator.date())
    if isinstance(field, TimeField):
        return (lambda x: generator.time())
    if isinstance(field, URLField):
        return (lambda x: generator.uri())
    if isinstance(field, SlugField):
        return (lambda x: generator.slug())
    if isinstance(field, IPAddressField):
        protocolIp = generator.randomElements(['ipv4', 'ipv6'])
        return (lambda x: getattr(generator, protocolIp)())
    if isinstance(field, EmailField):
        return (lambda x: generator.email())
    if isinstance(field, ImageField):
        return (lambda x: None)
    raise AttributeError(field)

dataset/ETHPy150Open joke2k/django-faker/django_faker/populator.py FieldTypeGuesser.guessFormat/original