Remove unnecessary code related to defining properties.
parent
0f5d35f82d
commit
12a22c0939
|
@ -65,9 +65,8 @@ class Property(object):
|
|||
raise ValueError("must equal '{0}'.".format(self._fixed_value))
|
||||
return value
|
||||
|
||||
def __init__(self, required=False, fixed=None, default=None, type=None):
|
||||
def __init__(self, required=False, fixed=None, default=None):
|
||||
self.required = required
|
||||
self.type = type
|
||||
if fixed:
|
||||
self._fixed_value = fixed
|
||||
self.clean = self._default_clean
|
||||
|
@ -191,6 +190,7 @@ class IntegerProperty(Property):
|
|||
|
||||
|
||||
class FloatProperty(Property):
|
||||
|
||||
def clean(self, value):
|
||||
try:
|
||||
return float(value)
|
||||
|
@ -311,12 +311,12 @@ REF_REGEX = re.compile("^[a-z][a-z-]+[a-z]--[0-9a-fA-F]{8}-[0-9a-fA-F]{4}"
|
|||
|
||||
class ReferenceProperty(Property):
|
||||
|
||||
def __init__(self, required=False, type=None):
|
||||
def __init__(self, type=None, **kwargs):
|
||||
"""
|
||||
references sometimes must be to a specific object type
|
||||
"""
|
||||
self.type = type
|
||||
super(ReferenceProperty, self).__init__(required, type=type)
|
||||
super(ReferenceProperty, self).__init__(**kwargs)
|
||||
|
||||
def clean(self, value):
|
||||
if isinstance(value, _STIXBase):
|
||||
|
@ -335,10 +335,6 @@ SELECTOR_REGEX = re.compile("^[a-z0-9_-]{3,250}(\\.(\\[\\d+\\]|[a-z0-9_-]{1,250}
|
|||
|
||||
class SelectorProperty(Property):
|
||||
|
||||
def __init__(self, type=None):
|
||||
# ignore type
|
||||
super(SelectorProperty, self).__init__()
|
||||
|
||||
def clean(self, value):
|
||||
if not SELECTOR_REGEX.match(value):
|
||||
raise ValueError("must adhere to selector syntax.")
|
||||
|
@ -356,9 +352,9 @@ class ObjectReferenceProperty(StringProperty):
|
|||
|
||||
class EmbeddedObjectProperty(Property):
|
||||
|
||||
def __init__(self, type, required=False):
|
||||
def __init__(self, type, **kwargs):
|
||||
self.type = type
|
||||
super(EmbeddedObjectProperty, self).__init__(required, type=type)
|
||||
super(EmbeddedObjectProperty, self).__init__(**kwargs)
|
||||
|
||||
def clean(self, value):
|
||||
if type(value) is dict:
|
||||
|
@ -385,9 +381,6 @@ class EnumProperty(StringProperty):
|
|||
|
||||
class PatternProperty(StringProperty):
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
super(PatternProperty, self).__init__(**kwargs)
|
||||
|
||||
def clean(self, value):
|
||||
str_value = super(PatternProperty, self).clean(value)
|
||||
errors = run_validator(str_value)
|
||||
|
|
Loading…
Reference in New Issue