MCPcopy Create free account
hub / github.com/STIXProject/python-stix / VocabField

Class VocabField

stix/common/vocabs.py:45–68  ·  view source on GitHub ↗

TypedField subclass for VocabString fields.

Source from the content-addressed store, hash-verified

43
44
45class VocabField(fields.TypedField):
46 """TypedField subclass for VocabString fields."""
47
48 def __init__(self, *args, **kwargs):
49 """Intercepts the __init__() call to TypedField.
50
51 Set the type that will be used in from_dict and from_obj calls to
52 :class:`VocabString`.
53
54 Set the type that will be used in ``__set__`` for casting as the
55 original ``type_`` argument, or :class:`VocabString` if no `type_`
56 argument was provided.
57
58 """
59 super(VocabField, self).__init__(*args, **kwargs)
60 self.factory = VocabFactory # force this factory
61
62 if self._unresolved_type is None:
63 self.type_ = VocabString
64
65 self._listfunc = partial(VocabList, type=self._unresolved_type)
66
67 def check_type(self, value):
68 return isinstance(value, VocabString)
69
70
71class VocabFactory(entities.EntityFactory):

Callers 15

EffectsClass · 0.90
IncidentCategoriesClass · 0.90
STIXHeaderClass · 0.90
IndicatorClass · 0.90
CourseOfActionClass · 0.90
NamesClass · 0.90
CampaignClass · 0.90
HeaderClass · 0.90
InformationSourceClass · 0.85
GenericRelationshipClass · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected