Version: 1.1.109

libtaxii.common Module

Common utility classes and functions used throughout libtaxii.

Functions

libtaxii.common.get_xml_parser()[source]

Return the XML parser currently in use.

If one has not already been set (via set_xml_parser()), a new etree.XMLParser is constructed with no_network=True and huge_tree=True.

libtaxii.common.set_xml_parser(xml_parser=None)[source]

Set the libtaxii.messages XML parser.

Parameters:xml_parser (etree.XMLParser) – The parser to use to parse TAXII XML.

Classes

class libtaxii.common.TAXIIBase[source]

Base class for all TAXII Messages and Message component types.

libtaxii users should not need to use this class directly.

__eq__(other, debug=False)[source]

Generic method used to check equality of objects of any TAXII type.

Also allows for print-based debugging output showing differences.

In order for subclasses to use this function, they must meet the following criteria: 1. All class properties start with one underscore. 2. The sort_key property is implemented.

Parameters:
  • self (object) – this object
  • other (object) – the object to compare self against.
  • debug (bool) – Whether or not to print debug statements as the equality comparison is performed.
classmethod from_dict(d)[source]

Create an instance of this class from a dictionary.

Subclasses must implement this method.

classmethod from_etree(src_etree)[source]

Create an instance of this class from an etree.

Subclasses must implement this method.

classmethod from_xml(xml)[source]

Create an instance of this class from XML.

Subclasses should not need to implement this method.

sort_key

This property allows list of TAXII objects to be compared efficiently. The __eq__ method uses this property to sort the lists before comparisons are made.

Subclasses must implement this property.

to_dict()[source]

Create a dictionary representation of this class.

Subclasses must implement this method.

to_etree()[source]

Create an etree representation of this class.

Subclasses must implement this method.

to_json()[source]

Create a JSON object of this class.

Assumes any binary content will be UTF-8 encoded.

to_text(line_prepend='')[source]

Create a nice looking (this is a subjective term!) textual representation of this class. Subclasses should implement this method.

Note that this is just a convenience method for making TAXII Messages nice to read for humans and may change drastically in future versions of libtaxii.

to_xml(pretty_print=False)[source]

Create an XML representation of this class.

Subclasses should not need to implement this method.