Version: 1.2.0.0
stix.base Module¶
Classes¶
- class stix.base.Entity¶
Base class for all classes in the STIX API.
- classmethod dict_from_object(entity_obj)¶
Convert from object representation to dict representation.
- find(id_)¶
Searches the children of a Entity implementation for an object with an id_ property that matches id_.
- classmethod from_dict(d, return_obj=None)¶
Convert from dict representation to object representation. This should be overriden by a subclass
- classmethod from_json(json_doc)¶
Parses the JSON document json_doc and returns a STIX Entity implementation instance.
Parameters: json_doc – Input JSON representation of a STIX entity. This can be a readable object or a JSON string. Returns: An implementation of – class:.Entity (e.g., STIXPackage).
- classmethod from_obj(obj, return_obj=None)¶
Create an object from a binding object
- classmethod object_from_dict(entity_dict)¶
Convert from dict representation to object representation.
- to_dict()¶
Converts a STIX Entity implementation into a Python dictionary. This may be overridden by derived classes.
- to_obj(return_obj=None, ns_info=None)¶
Converts an Entity into a binding object.
Note
This needs to be overridden by derived classes.
- to_xml(include_namespaces=True, include_schemalocs=False, ns_dict=None, schemaloc_dict=None, pretty=True, auto_namespace=True, encoding='utf-8')¶
Serializes a Entity instance to an XML string.
The default character encoding is utf-8 and can be set via the encoding parameter. If encoding is None, a unicode string is returned.
Parameters: - auto_namespace – Automatically discover and export XML namespaces for a STIX Entity instance.
- include_namespaces – Export namespace definitions in the output XML. Default is True.
- include_schemalocs – Export xsi:schemaLocation attribute in the output document. This will attempt to associate namespaces declared in the STIX document with schema locations. If a namespace cannot be resolved to a schemaLocation, a Python warning will be raised. Schemalocations will only be exported if include_namespaces is also True.
- ns_dict – Dictionary of XML definitions (namespace is key, alias is value) to include in the exported document. This must be passed in if auto_namespace is False.
- schemaloc_dict – Dictionary of XML namespace: schema location mappings to include in the exported document. These will only be included if auto_namespace is False.
- pretty – Pretty-print the XML.
- encoding – The output character encoding. Default is utf-8. If encoding is set to None, a unicode string is returned.
Returns: An XML string for this Entity instance. Default character encoding is utf-8.
- class stix.base.EntityList(*args)¶
Bases: _abcoll.MutableSequence, stix.base.Entity