A minor revision to stix2.versioning: it's silly to look up a
class in the registry when you have an instance of one of those classes. Because in that case, you can just get the class of the instance and not deal with the registry at all.pull/1/head
parent
5aadf1ae91
commit
92a478b39b
|
@ -168,11 +168,15 @@ def new_version(data, allow_custom=None, **kwargs):
|
||||||
# across versions.
|
# across versions.
|
||||||
sco_locked_props = []
|
sco_locked_props = []
|
||||||
if is_sco(data, "2.1"):
|
if is_sco(data, "2.1"):
|
||||||
cls = stix2.registry.class_for_type(
|
|
||||||
data["type"], stix_version, "observables"
|
|
||||||
)
|
|
||||||
uuid_ = uuid.UUID(data["id"][-36:])
|
uuid_ = uuid.UUID(data["id"][-36:])
|
||||||
if uuid_.variant == uuid.RFC_4122 and uuid_.version == 5:
|
if uuid_.variant == uuid.RFC_4122 and uuid_.version == 5:
|
||||||
|
if isinstance(data, stix2.base._Observable):
|
||||||
|
cls = data.__class__
|
||||||
|
else:
|
||||||
|
cls = stix2.registry.class_for_type(
|
||||||
|
data["type"], stix_version, "observables"
|
||||||
|
)
|
||||||
|
|
||||||
sco_locked_props = cls._id_contributing_properties
|
sco_locked_props = cls._id_contributing_properties
|
||||||
|
|
||||||
unchangable_properties = set()
|
unchangable_properties = set()
|
||||||
|
|
Loading…
Reference in New Issue