Ejemplo n.º 1
0
    def _populate_from_dict(self, attr_dict):
        # If this attribute is "plain", use it as the value and assume the
        # datatype was set correctly by the constructor of the particular
        # BaseProperty Subclass.
        if not isinstance(attr_dict, dict):
            self.value = attr_dict
        else:
            # This key should always be present
            self.value = attr_dict.get('value')

            # This defaults to False if missing
            self._force_datatype = attr_dict.get('force_datatype', False)

            # 'None' is fine if these keys are missing
            self.id_ = attr_dict.get('id')
            self.idref = attr_dict.get('idref')
            self.appears_random = attr_dict.get('appears_random')
            self.datatype = attr_dict.get('datatype')
            self.is_obfuscated = attr_dict.get('is_obfuscated')
            self.obfuscation_algorithm_ref = attr_dict.get('obfuscation_algorithm_ref')
            self.is_defanged = attr_dict.get('is_defanged')
            self.defanging_algorithm_ref = attr_dict.get('defanging_algorithm_ref')
            self.refanging_transform_type = attr_dict.get('refanging_transform_type')
            self.refanging_transform = attr_dict.get('refanging_transform')
            self.observed_encoding = attr_dict.get('observed_encoding')

            PatternFieldGroup.from_dict(attr_dict, self)
Ejemplo n.º 2
0
    def _populate_from_dict(self, attr_dict):
        # If this attribute is "plain", use it as the value and assume the
        # datatype was set correctly by the constructor of the particular
        # BaseProperty Subclass.
        if not isinstance(attr_dict, dict):
            self.value = attr_dict
        else:
            # This key should always be present
            self.value = attr_dict.get('value')

            # This defaults to False if missing
            self._force_datatype = attr_dict.get('force_datatype', False)

            # 'None' is fine if these keys are missing
            self.id_ = attr_dict.get('id')
            self.idref = attr_dict.get('idref')
            self.appears_random = attr_dict.get('appears_random')
            self.datatype = attr_dict.get('datatype')
            self.is_obfuscated = attr_dict.get('is_obfuscated')
            self.obfuscation_algorithm_ref = attr_dict.get(
                'obfuscation_algorithm_ref')
            self.is_defanged = attr_dict.get('is_defanged')
            self.defanging_algorithm_ref = attr_dict.get(
                'defanging_algorithm_ref')
            self.refanging_transform_type = attr_dict.get(
                'refanging_transform_type')
            self.refanging_transform = attr_dict.get('refanging_transform')
            self.observed_encoding = attr_dict.get('observed_encoding')

            PatternFieldGroup.from_dict(attr_dict, self)
Ejemplo n.º 3
0
    def from_dict(cls, vocab_dict):
        if not vocab_dict:
            return None

        vocab_str = cls()
        # xsi_type should be set automatically by the class's constructor.

        # In case this is a "plain" string, just set it.
        if not isinstance(vocab_dict, dict):
            vocab_str.value = vocab_dict
        else:
            vocab_str.xsi_type = vocab_dict.get('xsi:type', cls._XSI_TYPE)
            vocab_str.value = vocab_dict.get('value')
            vocab_str.vocab_name = vocab_dict.get('vocab_name')
            vocab_str.vocab_reference = vocab_dict.get('vocab_reference')

            PatternFieldGroup.from_dict(vocab_dict, vocab_str)

        return vocab_str
Ejemplo n.º 4
0
    def from_dict(cls, vocab_dict, return_obj=None):
        if not vocab_dict:
            return None

        if not return_obj:
            if isinstance(vocab_dict, dict):
                klass = VocabString.lookup_class(vocab_dict.get('xsi:type'))
                return_obj = klass()
            else:
                return_obj = cls()

        # In case this is a "plain" string, just set it.
        if not isinstance(vocab_dict, dict):
            return_obj.value = vocab_dict
        else:
            return_obj.xsi_type = vocab_dict.get('xsi:type', cls._XSI_TYPE)
            return_obj.value = vocab_dict.get('value')
            return_obj.vocab_name = vocab_dict.get('vocab_name')
            return_obj.vocab_reference = vocab_dict.get('vocab_reference')

            PatternFieldGroup.from_dict(vocab_dict, return_obj)

        return return_obj
Ejemplo n.º 5
0
    def from_dict(cls, vocab_dict, return_obj=None):
        if not vocab_dict:
            return None

        if not return_obj:
            if isinstance(vocab_dict, dict):
                klass = VocabString.lookup_class(vocab_dict.get('xsi:type'))
                return_obj = klass()
            else:
                return_obj = cls()

        # In case this is a "plain" string, just set it.
        if not isinstance(vocab_dict, dict):
            return_obj.value = vocab_dict
        else:
            return_obj.xsi_type = vocab_dict.get('xsi:type', cls._XSI_TYPE)
            return_obj.value = vocab_dict.get('value')
            return_obj.vocab_name = vocab_dict.get('vocab_name')
            return_obj.vocab_reference = vocab_dict.get('vocab_reference')

            PatternFieldGroup.from_dict(vocab_dict, return_obj)

        return return_obj