Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __load_fields(self):
""" Return scheme's fields. """
for fname in dir(self.__scheme):
if fname.startswith('_'):
continue
prop = getattr(self.__scheme, fname)
yield fname, t.Field(prop, fname)
def gen_value(self, field_name, field, fake=None, unique=False):
""" Generate values from basic types.
:return : (name, value) for later use
"""
fake = self.__fake if fake is None else fake
if not field:
field = t.Field(getattr(self.__scheme, field_name, None), field_name)
fab = self.get_fabric(field, field_name, fake=fake)
try:
value = fab()
except ValueError:
value = None
except Exception as exc:
LOGGER.exception(exc)
raise ValueError("Generation for %s (%s) has been stopped. Exception: %s" % (
field_name, self.__scheme.__name__, exc))
if unique and value is not SKIP_VALUE:
counter = 0
try:
while value in self.__gen_values[field_name]:
def __load_fields(self):
for fname, field in self.__scheme.__fields__.items():
yield fname, t.Field(field, fname)
def __load_fields(self):
private_fields = getattr(self.__scheme._meta, 'private_fields', [])
for field in private_fields:
yield field.name, t.Field(field, field.name)
for field in self.__scheme._meta.fields:
if isinstance(field, models.AutoField)\
and self.__mixer and self.__mixer.params.get('commit'):
continue
yield field.name, t.Field(field, field.name)
for field in self.__scheme._meta.local_many_to_many:
yield field.name, t.Field(field, field.name)
def __load_fields(self):
for attr in self.__scheme._attrs_:
yield attr.column, t.Field(attr, attr.column)
def __load_fields(self):
""" Prepare SQLALchemyTypeMixer.
Select columns and relations for data generation.
"""
mapper = self.__scheme._sa_class_manager.mapper
relations = set()
if hasattr(mapper, 'relationships'):
for rel in mapper.relationships:
relations |= rel.local_columns
yield rel.key, t.Field(rel, rel.key)
for key, column in mapper.columns.items():
if column not in relations:
yield key, t.Field(column, key)
def __load_fields(self):
""" Prepare SQLALchemyTypeMixer.
Select columns and relations for data generation.
"""
mapper = self.__scheme._sa_class_manager.mapper
relations = set()
if hasattr(mapper, 'relationships'):
for rel in mapper.relationships:
relations |= rel.local_columns
yield rel.key, t.Field(rel, rel.key)
for key, column in mapper.columns.items():
if column not in relations:
yield key, t.Field(column, key)
def __load_fields(self):
for fname, field in self.__scheme._fields.items():
yield fname, t.Field(field, fname)