From 12a22c0939dbcafb8bebca1361aec4598ae3fdf2 Mon Sep 17 00:00:00 2001 From: Greg Back Date: Thu, 5 Jul 2018 11:39:44 -0500 Subject: [PATCH] Remove unnecessary code related to defining properties. --- stix2/properties.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/stix2/properties.py b/stix2/properties.py index 39d383a..e8031a9 100644 --- a/stix2/properties.py +++ b/stix2/properties.py @@ -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)