Convert model metadata to class attributes.

        This function is called automatically after ``define()`` in new
        versions.

        :return: None
486393
def _init(self):
        
        assert self._name
        assert self._group

        # self.n = 0
        self.u = []
        self.name = []
        self.idx = []
        self.uid = {}

        if not self._unamey:
            self._unamey = self._algebs
        else:
            assert len(self._unamey) == len(self._algebs)

        if not self._unamex:
            self._unamex = self._states
        else:
            assert len(self._unamex) == len(self._states)

        for item in self._data.keys():
            self.__dict__[item] = []

        for bus in self._ac.keys():
            for var in self._ac[bus]:
                self.__dict__[var] = []
        for node in self._dc.keys():
            for var in self._dc[node]:
                self.__dict__[var] = []

        for var in self._states + self._algebs + self._service:
            self.__dict__[var] = []

        self._flags['sysbase'] = False
        self._flags['allocate'] = False
        self._flags['address'] = False
1299349
def _model_to_dict(model, ignore):
        
        return {attr: value for attr, value in model.__dict__.items()
                if not attr.startswith('_') and attr not in ignore}
972374
def fileattr_from_metadata(md):
    # type: (dict) -> collections.namedtuple
    
    try:
        mdattr = json.loads(
            md[JSON_KEY_BLOBXFER_METADATA])[_JSON_KEY_FILE_ATTRIBUTES]
    except (KeyError, TypeError):
        return None
    else:
        if blobxfer.util.on_windows():
            global _FILEATTR_WARNED_ON_WINDOWS
            if not _FILEATTR_WARNED_ON_WINDOWS:
                _FILEATTR_WARNED_ON_WINDOWS = True
                logger.warning(
                    'file attributes store/restore on Windows is not '
                    'supported yet')
            fileattr = None
        else:
            try:
                fileattr = PosixFileAttr(
                    mode=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_MODE],
                    uid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_UID],
                    gid=mdattr[_JSON_KEY_FILE_ATTRIBUTES_POSIX][
                        _JSON_KEY_FILE_ATTRIBUTES_GID],
                )
            except KeyError:
                fileattr = None
        return fileattr
1139474
def get_meta(cls):
    
    merged_attributes = Struct()
    for class_ in reversed(cls.mro()):
        if hasattr(class_, 'Meta'):
            for key, value in class_.Meta.__dict__.items():
                merged_attributes[key] = value
    return merged_attributes
1157536
def make_instance_to_initdict(attributes: List[str]) -> InstanceToDictFnType:
    
    def custom_instance_to_initdict(x: Instance) -> InitDict:
        kwargs = {}
        for a in attributes:
            kwargs[a] = getattr(x, a)
        return kwargs_to_initdict(kwargs)

    return custom_instance_to_initdict
617242
def model_setattr():
    

    def model_setattr(value, context, **_params):
        setattr(context["model"], context["key"], value)
        return _attr()

    return model_setattr
1169457
def restore_model(cls, data):
    
    obj = cls()
    for field in data:
        setattr(obj, field, data[field][Field.VALUE])

    return obj
140374
def model_field_attr(model, model_field, attr):
    
    fields = dict([(field.name, field) for field in model._meta.fields])
    return getattr(fields[model_field], attr)
866859
def meta(cls):
        """"""
        if getattr(cls, '__from_class__', None) is not None:
            cls = cls.__from_class__
        attribute_info = {}
        for name, value in cls.__table__.columns.items():
            attribute_info[name] = str(value.type).lower()

        return {cls.__name__: attribute_info}
261967
def to_set_field(cls):
    
    class SetConverter(object):

        def __init__(self, cls):
            self._cls = cls

        @property
        def cls(self):
            return resolve_class(self._cls)

        def __call__(self, values):
            values = values or set()
            args = {to_model(self.cls, value) for value in values}
            return TypedSet(cls=self.cls, args=args)

    return SetConverter(cls)
1020964
def __deserialize_model(self, data, klass):
        
        instance = klass()

        if not instance.swagger_types:
            return data

        for attr, attr_type in iteritems(instance.swagger_types):
            if data is not None \
               and instance.attribute_map[attr] in data\
               and isinstance(data, (list, dict)):
                value = data[instance.attribute_map[attr]]
                setattr(instance, '_' + attr, self.__deserialize(value, attr_type))

        return instance
1226099
def parse_attributes(attributes=None, classname=None):
  
  if not attributes:
    attributes = {}
  attributes.setdefault('class', DEFAULT_CLASS_NAME)
  # If `classname` is specified, it overwrites `class` property in `attributes`.
  if classname:
    attributes['class'] = classname
  return attributes
1309468
def get_class_field(cls, field_name):
        
        if not cls.has_field(field_name):
            raise AttributeError('"%s" is not a field for the model "%s"' %
                                 (field_name, cls.__name__))

        field = getattr(cls, '_redis_attr_%s' % field_name)

        return field
132237
def transfer_metadata_to_dict(self, meta):
        
        dic = {}
        arr = meta.strip(' ,').split(',')
        for i in arr:
            temp = i.split('=')
            key = temp[0].strip()
            value = temp[1].strip()
            dic[key] = value
        return dic
419219
def from_entity(cls, entity: Entity) -> 'DictModel':
        
        dict_obj = {}
        for field_name in entity.meta_.attributes:
            dict_obj[field_name] = getattr(entity, field_name)
        return dict_obj
675923
def copy(self, name=None, description=None, meta=None):
        
        cls = self.__class__
        kwargs = self._rel(copy=True)
        kwargs.update(self._data(copy=True))
        if name is not None:
            kwargs['name'] = name
        if description is not None:
            kwargs['description'] = description
        if meta is not None:
            kwargs['meta'] = meta
        return cls(**kwargs)
1068670
def _convert_to_db_tc_metadata(tc_metadata):
        
        db_meta = copy.deepcopy(tc_metadata)

        # tcid is a mandatory field, it should throw an error if it is missing
        db_meta['tcid'] = db_meta['name']
        del db_meta['name']

        # Encapsulate current status inside dictionary
        if 'status' in db_meta:
            status = db_meta['status']
            del db_meta['status']
            db_meta['status'] = {'value': status}

        # Node and dut information
        if 'requirements' in db_meta:
            db_meta['requirements']['node'] = {'count': 1}
            try:
                count = db_meta['requirements']['duts']['*']['count']
                db_meta['requirements']['node']['count'] = count
            except KeyError:
                pass

        # Collect and pack other info from meta
        db_meta['other_info'] = {}
        if 'title' in db_meta:
            db_meta['other_info']['title'] = db_meta['title']
            del db_meta['title']

        if 'feature' in db_meta:
            db_meta['other_info']['features'] = db_meta['feature']
            del db_meta['feature']
        else:
            db_meta['other_info']['features'] = ['unknown']

        if 'component' in db_meta:
            db_meta['other_info']['components'] = db_meta["component"]
            del db_meta['component']

        return db_meta