Commit Graph

7 Commits (f9b9e0d2d7b9684c6ed9932ea922995aca5d775b)

Author SHA1 Message Date
Michael Chisholm 38067a6ec7 pre-commit stylistic fixes 2021-01-20 20:49:01 -05:00
Michael Chisholm 473e7d0068 Change versioning module to use some of the is_* utility
functions.  Changed some ">= 2.1" stix version semantics to be
"== 2.1", because we don't have any version >= 2.1, so they are
currently equivalent, and the is_*() functions don't support
STIX version ranges.  They only support exact versions.  We can
look at this again if a newer STIX version ever emerges.

Also added a class_for_type() function to the registry module,
which was useful for the versioning module changes described
above.  I thought that function would be helpful in the parsing
module, to simplify code there, so I changed that module a bit
to use it.
2021-01-20 16:59:39 -05:00
Michael Chisholm db1d0b736b Remove registry.get_stix2_class_maps(), since now that the
class map structure is keyed by normal "X.Y" style versions,
the convenience that function provided is no longer necessary.
So it no longer makes sense to have the function (at least,
not for that reason).  Change users of that function to use
the STIX2_OBJ_MAPS structure directly.
2021-01-20 16:59:39 -05:00
Michael Chisholm f88fba6751 Change the stix2 class map structure to be keyed at the top
level with STIX versions in the same format as is used everywhere
else in the API: "X.Y", as opposed to the "vXY" format used by
the version-specific python packages.  This eliminates all of
the awkward conversion from public API format to "vXX" format.

Also a little bit of code rearranging in the registration module
to ensure that some STIX 2.1-specific checks are done whether
version 2.1 is given explicitly or is defaulted to.

In the same module I also added a missing import of
stix2.properties, since my IDE was claiming it could not find a
function from that module.
2021-01-20 16:59:38 -05:00
Michael Chisholm 24307626b0 Move get_stix2_class_maps() from .utils to .registry (since it's
really just a simple accessor into the class maps table), and
change other code to use it, in places where it was simple and
made sense.
2021-01-20 16:59:38 -05:00
Chris Lenk 7de5c458bb Fix import sort order 2021-01-15 10:27:39 -05:00
Michael Chisholm f51e309775 Refactor stix2.parsing into more focused modules:
- stix2.registry, which contains the class mapping structure
  and code for scanning stix2 modules for its initial population
- stix2.registration, which contains code used to register custom
  STIX types with the registry
- stix2.parsing, which contains code for creating instances of
  registered stix2 classes from raw dicts.

This is intended to reduce circular import problems, by giving
dependent code the ability to import a module which has exactly
the functionality it needs, without pulling a lot of other stuff
it doesn't need.  Fewer imports means less chance of an import
cycle.
2021-01-08 22:08:33 -05:00