|
5 | 5 |
|
6 | 6 | import stix |
7 | 7 | import stix.indicator.test_mechanism |
| 8 | +from stix.common.vocabs import VocabField |
8 | 9 | from stix.common import EncodedCDATA, StructuredTextList, VocabString |
9 | 10 | from stix.indicator.test_mechanism import _BaseTestMechanism |
10 | 11 | import stix.bindings.extensions.test_mechanism.generic as generic_tm_binding |
11 | 12 |
|
| 13 | + |
12 | 14 | @stix.register_extension |
13 | 15 | class GenericTestMechanism(_BaseTestMechanism): |
14 | 16 | _namespace = "http://stix.mitre.org/extensions/TestMechanism#Generic-1" |
15 | 17 | _binding = generic_tm_binding |
16 | 18 | _binding_class = _binding.GenericTestMechanismType |
17 | 19 | _XSI_TYPE = "genericTM:GenericTestMechanismType" |
18 | 20 |
|
19 | | - reference_location = fields.TypedField("Reference_Location") |
| 21 | + reference_location = fields.TypedField("reference_location") |
20 | 22 | descriptions = fields.TypedField("Description", StructuredTextList) |
21 | 23 | specification = fields.TypedField("Specification", EncodedCDATA) |
22 | | - type_ = fields.TypedField("type", VocabString, key_name="type") |
| 24 | + type_ = VocabField("Type") |
23 | 25 |
|
24 | 26 | def __init__(self, id_=None, idref=None): |
25 | 27 | super(GenericTestMechanism, self).__init__(id_=id_, idref=idref) |
26 | | - self.reference_location = None |
27 | | - self.description = None |
28 | | - self.type_ = None |
29 | | - self.specification = None |
30 | | - |
31 | | - """ |
32 | | - @property |
33 | | - def specification(self): |
34 | | - return self._specification |
35 | | - |
36 | | - @specification.setter |
37 | | - def specification(self, value): |
38 | | - if not value: |
39 | | - self._specification = None |
40 | | - if isinstance(value, EncodedCDATA): |
41 | | - self._specification = value |
42 | | - else: |
43 | | - self._specification = EncodedCDATA(value=value) |
44 | | - """ |
45 | | - |
| 28 | + self.descriptions = StructuredTextList() |
| 29 | + |
46 | 30 | @property |
47 | 31 | def description(self): |
48 | 32 | """A single description about the contents or purpose of this object. |
@@ -71,56 +55,3 @@ def add_description(self, description): |
71 | 55 |
|
72 | 56 | """ |
73 | 57 | self.descriptions.add(description) |
74 | | - |
75 | | - """ |
76 | | - @property |
77 | | - def type_(self): |
78 | | - return self._type |
79 | | - |
80 | | - @type_.setter |
81 | | - def type_(self, value): |
82 | | - if not value: |
83 | | - self._type = None |
84 | | - elif isinstance(value, VocabString): |
85 | | - self._type = value |
86 | | - else: |
87 | | - self._type = VocabString(value) |
88 | | - """ |
89 | | - |
90 | | - @classmethod |
91 | | - def from_obj(cls, obj): |
92 | | - if not obj: |
93 | | - return None |
94 | | - if not return_obj: |
95 | | - return_obj = cls() |
96 | | - |
97 | | - super(GenericTestMechanism, cls).from_obj(obj, return_obj) |
98 | | - return_obj.reference_location = obj.reference_location |
99 | | - return_obj.descriptions = StructuredTextList.from_obj(obj.Description) |
100 | | - return_obj.type_ = VocabString.from_obj(obj.Type) |
101 | | - return_obj.specification = EncodedCDATA.from_obj(obj.Specification) |
102 | | - |
103 | | - return return_obj |
104 | | - |
105 | | - def to_obj(self, ns_info=None): |
106 | | - obj = super(GenericTestMechanism, self).to_obj(ns_info=ns_info) |
107 | | - |
108 | | - return obj |
109 | | - |
110 | | - @classmethod |
111 | | - def from_dict(cls, d): |
112 | | - if not d: |
113 | | - return None |
114 | | - if not return_obj: |
115 | | - return_obj = cls() |
116 | | - |
117 | | - super(GenericTestMechanism, cls).from_dict(d, return_obj) |
118 | | - return_obj.reference_location = d.get('reference_location') |
119 | | - return_obj.descriptions = StructuredTextList.from_dict(d.get('description')) |
120 | | - return_obj.type_ = VocabString.from_dict(d.get('type')) |
121 | | - return_obj.specification = EncodedCDATA.from_dict(d.get('specification')) |
122 | | - |
123 | | - return return_obj |
124 | | - |
125 | | - def to_dict(self): |
126 | | - return super(GenericTestMechanism, self).to_dict() |
0 commit comments