Update README, add DEFAULT_VERSION

stix2.0
Emmanuelle Vargas-Gonzalez 2017-11-01 10:48:28 -04:00
parent ef20860400
commit 06a50b0178
4 changed files with 12 additions and 9 deletions

View File

@ -65,8 +65,9 @@ For more in-depth documentation, please see `https://stix2.readthedocs.io/ <http
STIX 2.X Technical Specification Support
----------------------------------------
The `stix2` Python library is built to support multiple versions of the STIX
Technical Specification. With every major release of stix2 the ``import stix2``
This version of python-stix2 supports STIX 2.0 by default. Although, the `stix2`
Python library is built to support multiple versions of the STIX Technical
Specification. With every major release of stix2 the ``import stix2``
statement will automatically load the SDO/SROs equivalent to the most recent
supported 2.X Technical Specification. Please see the library documentation
for more details.

View File

@ -203,7 +203,7 @@
"source": [
"### How will custom work\n",
"\n",
"CustomObjects, CustomObservable, CustomMarking and CustomExtensions must be registered explicitly by STIX version. This is a design decision since properties or requirements may change as the STIX Technical Specification advances.\n",
"CustomObject, CustomObservable, CustomMarking and CustomExtension must be registered explicitly by STIX version. This is a design decision since properties or requirements may change as the STIX Technical Specification advances.\n",
"\n",
"You can perform this by,"
]

View File

@ -49,7 +49,9 @@ from .sources.memory import MemorySink, MemorySource, MemoryStore
from .sources.taxii import (TAXIICollectionSink, TAXIICollectionSource,
TAXIICollectionStore)
from .utils import get_dict, new_version, revoke
from .v20 import * # This import should always be the latest STIX 2.X version
from .v20 import * # This import will always be the latest STIX 2.X version
from .version import __version__
_collect_stix2_obj_maps()
DEFAULT_VERSION = "2.0" # Default version will always be the latest STIX 2.X version

View File

@ -4,7 +4,7 @@ from collections import OrderedDict
import importlib
import pkgutil
from . import exceptions
from . import DEFAULT_VERSION, exceptions
from .base import _STIXBase
from .properties import IDProperty, ListProperty, Property, TypeProperty
from .utils import get_dict
@ -78,11 +78,11 @@ def parse(data, allow_custom=False, version=None):
"""
if not version:
# Use latest version
OBJ_MAP = STIX2_OBJ_MAPS[sorted(STIX2_OBJ_MAPS.keys())[-1]]
v = 'v' + DEFAULT_VERSION.replace('.', '')
else:
v = 'v' + version.replace('.', '')
OBJ_MAP = STIX2_OBJ_MAPS[v]
OBJ_MAP = STIX2_OBJ_MAPS[v]
obj = get_dict(data)
if 'type' not in obj:
@ -105,11 +105,11 @@ def _register_type(new_type, version=None):
"""
if not version:
# Use latest version
OBJ_MAP = STIX2_OBJ_MAPS[sorted(STIX2_OBJ_MAPS.keys())[-1]]
v = 'v' + DEFAULT_VERSION.replace('.', '')
else:
v = 'v' + version.replace('.', '')
OBJ_MAP = STIX2_OBJ_MAPS[v]
OBJ_MAP = STIX2_OBJ_MAPS[v]
OBJ_MAP[new_type._type] = new_type