Move CallableValues to prevent duplicate code
parent
34002c4f7c
commit
1ad64dfc0c
|
@ -11,7 +11,7 @@ import uuid
|
|||
from six import string_types, text_type
|
||||
from stix2patterns.validator import run_validator
|
||||
|
||||
from .base import _STIXBase
|
||||
from .base import _Observable, _STIXBase
|
||||
from .core import STIX2_OBJ_MAPS, parse, parse_observable
|
||||
from .exceptions import CustomContentError, DictionaryKeyError
|
||||
from .utils import _get_dict, get_class_hierarchy_names, parse_into_datetime
|
||||
|
@ -167,6 +167,19 @@ class ListProperty(Property):
|
|||
return result
|
||||
|
||||
|
||||
class CallableValues(list):
|
||||
"""Wrapper to allow `values()` method on WindowsRegistryKey objects.
|
||||
Needed because `values` is also a property.
|
||||
"""
|
||||
|
||||
def __init__(self, parent_instance, *args, **kwargs):
|
||||
self.parent_instance = parent_instance
|
||||
super(CallableValues, self).__init__(*args, **kwargs)
|
||||
|
||||
def __call__(self):
|
||||
return _Observable.values(self.parent_instance)
|
||||
|
||||
|
||||
class StringProperty(Property):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
|
|
|
@ -12,7 +12,7 @@ from ..base import _Extension, _Observable, _STIXBase
|
|||
from ..custom import _custom_extension_builder, _custom_observable_builder
|
||||
from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError
|
||||
from ..properties import (
|
||||
BinaryProperty, BooleanProperty, DictionaryProperty,
|
||||
BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty,
|
||||
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
||||
HashesProperty, HexProperty, IntegerProperty, ListProperty,
|
||||
ObjectReferenceProperty, StringProperty, TimestampProperty, TypeProperty,
|
||||
|
@ -706,19 +706,6 @@ class WindowsRegistryValueType(_STIXBase):
|
|||
])
|
||||
|
||||
|
||||
class CallableValues(list):
|
||||
"""Wrapper to allow `values()` method on WindowsRegistryKey objects.
|
||||
Needed because `values` is also a property.
|
||||
"""
|
||||
|
||||
def __init__(self, parent_instance, *args, **kwargs):
|
||||
self.parent_instance = parent_instance
|
||||
super(CallableValues, self).__init__(*args, **kwargs)
|
||||
|
||||
def __call__(self):
|
||||
return _Observable.values(self.parent_instance)
|
||||
|
||||
|
||||
class WindowsRegistryKey(_Observable):
|
||||
"""For more detailed information on this object's properties, see
|
||||
`the STIX 2.0 specification <http://docs.oasis-open.org/cti/stix/v2.0/cs01/part4-cyber-observable-objects/stix-v2.0-cs01-part4-cyber-observable-objects.html#_Toc496716291>`__.
|
||||
|
|
|
@ -12,7 +12,7 @@ from ..base import _Extension, _Observable, _STIXBase
|
|||
from ..custom import _custom_extension_builder, _custom_observable_builder
|
||||
from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError
|
||||
from ..properties import (
|
||||
BinaryProperty, BooleanProperty, DictionaryProperty,
|
||||
BinaryProperty, BooleanProperty, CallableValues, DictionaryProperty,
|
||||
EmbeddedObjectProperty, EnumProperty, ExtensionsProperty, FloatProperty,
|
||||
HashesProperty, HexProperty, IntegerProperty, ListProperty,
|
||||
ObjectReferenceProperty, StringProperty, TimestampProperty, TypeProperty,
|
||||
|
@ -758,19 +758,6 @@ class WindowsRegistryValueType(_STIXBase):
|
|||
])
|
||||
|
||||
|
||||
class CallableValues(list):
|
||||
"""Wrapper to allow `values()` method on WindowsRegistryKey objects.
|
||||
Needed because `values` is also a property.
|
||||
"""
|
||||
|
||||
def __init__(self, parent_instance, *args, **kwargs):
|
||||
self.parent_instance = parent_instance
|
||||
super(CallableValues, self).__init__(*args, **kwargs)
|
||||
|
||||
def __call__(self):
|
||||
return _Observable.values(self.parent_instance)
|
||||
|
||||
|
||||
class WindowsRegistryKey(_Observable):
|
||||
# TODO: Add link
|
||||
"""For more detailed information on this object's properties, see
|
||||
|
|
Loading…
Reference in New Issue