A class decorator to pull out `_list_fields` from a mixin class for use with a `datatype`.
357240
def _algebraic_data(metaclass):
  """"""
  def wrapper(cls):
    cls.__bases__ += (metaclass,)
    cls._list_fields = metaclass._list_fields
    return cls
  return wrapper
12800
def _generate_union_class_vars(self, data_type):
        
        lineno = self.lineno
        if data_type.catch_all_field:
            self.emit("_catch_all = '%s'" % data_type.catch_all_field.name)
        elif not data_type.parent_type:
            self.emit('_catch_all = None')

        # Generate stubs for class variables so that IDEs like PyCharms have an
        # easier time detecting their existence.
        for field in data_type.fields:
            if is_void_type(field.data_type):
                field_name = fmt_var(field.name)
                self.emit('# Attribute is overwritten below the class definition')
                self.emit('{} = None'.format(field_name))

        if lineno != self.lineno:
            self.emit()
788952
def declarative_fields(cls_filter, meta_base=type, extra_attr_name='base_fields'):
    
    def __new__(cls, name, bases, attrs):
        attrs[extra_attr_name] = fields = get_declared_fields(bases, attrs, cls_filter,
                extra_attr_name=extra_attr_name)
        attrs[extra_attr_name + '_names'] = set(fields.keys())
        new_class = meta_base.__new__(cls, name, bases, attrs)
        return new_class

    return type('', (meta_base,), {'__new__': __new__})
624685
def list_deep_types(list_):
    
    type_list = []
    for item in list_:
        if util_type.is_listlike(item):
            type_list.extend(list_deep_types(item))
        else:
            type_list.append(type(item))
    return type_list
1328317
def wrap(self, methodName, types, skip=2):
        

        def handler(fields):
            try:
                args = [
                    field if typ is str else
                    int(field or 0) if typ is int else
                    float(field or 0) if typ is float else
                    bool(int(field or 0))
                    for (typ, field) in zip(types, fields[skip:])]
                method(*args)
            except Exception:
                self.logger.exception(f'Error for {methodName}:')

        method = getattr(self.wrapper, methodName, None)
        return handler if method else lambda *args: None
480920
def list_encoder(values, instance, field: Field):
    """"""
    return [field.to_db_value(element, instance) for element in values]
1222974
def get_field(self, name):
        
        # TODO could use a generator here
        prog = re.compile(name)
        l = []
        for i in self.get_classes():
            for j in i.get_fields():
                if prog.match(j.get_name()):
                    l.append(j)
        return l
1162456
def prepare_fields(fields):
    
    def process_item(value):
        if not isinstance(value, NUMERIC_TYPES):
            if isinstance(value, six.string_types):
                # encode utf-8 to unicode, if necessary
                return force_text(value)
            else:
                if isinstance(value, dict):
                    return prepare_fields(value)
                elif isinstance(value, list):
                    return list(map(process_item, value))

                return six.text_type(value)
        return value

    return dict((key, process_item(value))
                for key, value
                in fields.items())
147413
def mk_field(field):
  
  assert len(field) == 1
  identifier, contents = next(iter(field.items()))
  contents = dict(list({'units': '', 'n_with_values': 0}.items()) + list(contents.items()))
  return sbp.resolve_type(sbp.Field(identifier=identifier,
                                    type_id=contents.pop('type'),
                                    options=contents))
994438
def p_list_type(self, p):
        ''''''
        p[0] = ast.ListType(value_type=p[3], annotations=p[5])
676771
def make_plus_fields(obj):
    
    fields = standard_fields.get(obj['_type'], dict())
    return _make_plus_helper(obj, fields)
452096
def use_schema(schema, list_view=False, locations=None):
    

    def decorator(func):
        @functools.wraps(func)
        def wrapped(*args, **kwargs):
            use_args_wrapper = parser.use_args(schema, locations=locations)
            # Function wrapped with use_args
            func_with_args = use_args_wrapper(func)
            ret = func_with_args(*args, **kwargs)
            # Serialize and jsonify the return value
            return jsonify(schema.dump(ret, many=list_view).data)

        return wrapped

    return decorator
1024387
def _from_fields(self, fields):
        '''
        

        '''
        return _np.dtype(self.dtype()).type(next(fields))
1330127
def _feature_to_fields(f, jsonify=True):
    
    x = []
    for k in constants._keys:
        v = getattr(f, k)
        if jsonify and (k in ('attributes', 'extra')):
            x.append(_jsonify(v))
        else:
            x.append(v)
    return tuple(x)
207127
def as_list(callable):
    """"""
    @wraps(callable)
    def wrapper(value_iter):
        return [callable(value) for value in value_iter]

    return wrapper
406217
def maybe_cast_list(value, types):
    
    if not isinstance(value, list):
        return value

    if type(types) not in (list, tuple):
        types = (types,)

    for list_type in types:
        if issubclass(list_type, list):
            try:
                return list_type(value)
            except (TypeError, ValueError):
                pass
    return value
688682
def mixin (cls):
    
    cls._events = {}
    cls.bind = Pyevent.bind.__func__
    cls.unbind = Pyevent.unbind.__func__
    cls.trigger = Pyevent.trigger.__func__
    return cls