From e513c8d638bd19803273a813ceedf0202c38d967 Mon Sep 17 00:00:00 2001 From: Emmanuelle Vargas-Gonzalez Date: Wed, 11 Jul 2018 08:11:47 -0400 Subject: [PATCH] Hide builder methods in 'custom.py' and update imports accordingly --- stix2/custom.py | 8 ++++---- stix2/v20/common.py | 4 ++-- stix2/v20/observables.py | 6 +++--- stix2/v20/sdo.py | 4 ++-- stix2/v21/common.py | 4 ++-- stix2/v21/observables.py | 6 +++--- stix2/v21/sdo.py | 4 ++-- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/stix2/custom.py b/stix2/custom.py index 5be3c57..8725cdb 100644 --- a/stix2/custom.py +++ b/stix2/custom.py @@ -7,7 +7,7 @@ from .core import (_register_object, _register_marking, _register_observable, from .utils import TYPE_REGEX, get_class_hierarchy_names -def custom_object_builder(cls, type, properties, version): +def _custom_object_builder(cls, type, properties, version): class _CustomObject(cls, STIXDomainObject): if not re.match(TYPE_REGEX, type): @@ -38,7 +38,7 @@ def custom_object_builder(cls, type, properties, version): return _CustomObject -def custom_marking_builder(cls, type, properties, version): +def _custom_marking_builder(cls, type, properties, version): class _CustomMarking(cls, _STIXBase): if not properties or not isinstance(properties, list): @@ -62,7 +62,7 @@ def custom_marking_builder(cls, type, properties, version): return _CustomMarking -def custom_observable_builder(cls, type, properties, version): +def _custom_observable_builder(cls, type, properties, version): class _CustomObservable(cls, _Observable): if not re.match(TYPE_REGEX, type): @@ -102,7 +102,7 @@ def custom_observable_builder(cls, type, properties, version): return _CustomObservable -def custom_extension_builder(cls, observable, type, properties, version): +def _custom_extension_builder(cls, observable, type, properties, version): if not observable or not issubclass(observable, _Observable): raise ValueError("'observable' must be a valid Observable class!") diff --git a/stix2/v20/common.py b/stix2/v20/common.py index 0007631..1756233 100644 --- a/stix2/v20/common.py +++ b/stix2/v20/common.py @@ -3,7 +3,7 @@ from collections import OrderedDict from ..base import _STIXBase -from ..custom import custom_marking_builder +from ..custom import _custom_marking_builder from ..markings import _MarkingsMixin from ..properties import (HashesProperty, IDProperty, ListProperty, Property, ReferenceProperty, SelectorProperty, StringProperty, @@ -147,7 +147,7 @@ def CustomMarking(type='x-custom-marking', properties=None): """ def wrapper(cls): - return custom_marking_builder(cls, type, properties, '2.0') + return _custom_marking_builder(cls, type, properties, '2.0') return wrapper diff --git a/stix2/v20/observables.py b/stix2/v20/observables.py index 84d007a..5bae00e 100644 --- a/stix2/v20/observables.py +++ b/stix2/v20/observables.py @@ -9,7 +9,7 @@ from collections import OrderedDict import itertools from ..base import _Extension, _Observable, _STIXBase -from ..custom import custom_extension_builder, custom_observable_builder +from ..custom import _custom_extension_builder, _custom_observable_builder from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError from ..properties import (BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, @@ -784,7 +784,7 @@ def CustomObservable(type='x-custom-observable', properties=None): properties, [('extensions', ExtensionsProperty(enclosing_type=type))] ])) - return custom_observable_builder(cls, type, _properties, '2.0') + return _custom_observable_builder(cls, type, _properties, '2.0') return wrapper @@ -792,5 +792,5 @@ def CustomExtension(observable=None, type='x-custom-observable-ext', properties= """Decorator for custom extensions to STIX Cyber Observables. """ def wrapper(cls): - return custom_extension_builder(cls, observable, type, properties, '2.0') + return _custom_extension_builder(cls, observable, type, properties, '2.0') return wrapper diff --git a/stix2/v20/sdo.py b/stix2/v20/sdo.py index 5a99c16..ca96c26 100644 --- a/stix2/v20/sdo.py +++ b/stix2/v20/sdo.py @@ -5,7 +5,7 @@ from collections import OrderedDict import itertools from ..core import STIXDomainObject -from ..custom import custom_object_builder +from ..custom import _custom_object_builder from ..properties import (BooleanProperty, IDProperty, IntegerProperty, ListProperty, ObservableProperty, PatternProperty, ReferenceProperty, StringProperty, TimestampProperty, @@ -366,6 +366,6 @@ def CustomObject(type='x-custom-type', properties=None): ], sorted([x for x in properties if x[0].startswith('x_')], key=lambda x: x[0]) ])) - return custom_object_builder(cls, type, _properties, '2.0') + return _custom_object_builder(cls, type, _properties, '2.0') return wrapper diff --git a/stix2/v21/common.py b/stix2/v21/common.py index 75df2ff..e822d42 100644 --- a/stix2/v21/common.py +++ b/stix2/v21/common.py @@ -3,7 +3,7 @@ from collections import OrderedDict from ..base import _STIXBase -from ..custom import custom_marking_builder +from ..custom import _custom_marking_builder from ..markings import _MarkingsMixin from ..properties import (BooleanProperty, DictionaryProperty, HashesProperty, IDProperty, ListProperty, Property, @@ -186,7 +186,7 @@ def CustomMarking(type='x-custom-marking', properties=None): """ def wrapper(cls): - return custom_marking_builder(cls, type, properties, '2.1') + return _custom_marking_builder(cls, type, properties, '2.1') return wrapper diff --git a/stix2/v21/observables.py b/stix2/v21/observables.py index 5ae6340..c5db7cf 100644 --- a/stix2/v21/observables.py +++ b/stix2/v21/observables.py @@ -9,7 +9,7 @@ from collections import OrderedDict import itertools from ..base import _Extension, _Observable, _STIXBase -from ..custom import custom_extension_builder, custom_observable_builder +from ..custom import _custom_extension_builder, _custom_observable_builder from ..exceptions import AtLeastOnePropertyError, DependentPropertiesError from ..properties import (BinaryProperty, BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, @@ -820,7 +820,7 @@ def CustomObservable(type='x-custom-observable', properties=None): properties, [('extensions', ExtensionsProperty(spec_version='2.1', enclosing_type=type))] ])) - return custom_observable_builder(cls, type, _properties, '2.1') + return _custom_observable_builder(cls, type, _properties, '2.1') return wrapper @@ -828,5 +828,5 @@ def CustomExtension(observable=None, type='x-custom-observable-ext', properties= """Decorator for custom extensions to STIX Cyber Observables. """ def wrapper(cls): - return custom_extension_builder(cls, observable, type, properties, '2.1') + return _custom_extension_builder(cls, observable, type, properties, '2.1') return wrapper diff --git a/stix2/v21/sdo.py b/stix2/v21/sdo.py index ecda6f2..f8266a8 100644 --- a/stix2/v21/sdo.py +++ b/stix2/v21/sdo.py @@ -5,7 +5,7 @@ import itertools from ..base import _STIXBase from ..core import STIXDomainObject -from ..custom import custom_object_builder +from ..custom import _custom_object_builder from ..properties import (BooleanProperty, DictionaryProperty, EmbeddedObjectProperty, EnumProperty, FloatProperty, IDProperty, IntegerProperty, ListProperty, @@ -550,6 +550,6 @@ def CustomObject(type='x-custom-type', properties=None): ], sorted([x for x in properties if x[0].startswith('x_')], key=lambda x: x[0]) ])) - return custom_object_builder(cls, type, _properties, '2.1') + return _custom_object_builder(cls, type, _properties, '2.1') return wrapper