10.7.6. Utilities for SOAP API Adapters

pytan3.adapters.soap_envelope(cmd, obj, opts=None)[source]

Construct a SOAP envelope with the request command, obj, and options.

Parameters:
  • cmd (str) – Command to use for request.
  • obj (dict) – Object(s) to use for request.
  • options (dict, optional) –

    Options to use for request.

    Defaults to: None.

Returns:

dict

pytan3.adapters.re_soap_tag(text, tag, limit=4000, pattern='<{t}>(.*?)</{t}>')[source]

Search for tag in text[:limit] using pattern.

Parameters:
  • text (str) – Text to search for pattern.
  • tag (str) – Tag name to use in pattern as ‘t’.
  • limit (int, optional) –

    Length to limit text to when searching for pattern.

    Defaults to: 4000.

  • pattern (str, optional) –

    Pattern to use when searching for tag.

    Defaults to: r’<{e}>(.*?)</{e}>’

Notes

Given text is 4 GB and pattern is expected at top of text:
  • if head is None and pattern not found: 131 seconds
  • if head is None and pattern found: 0 seconds
  • if head is 4000 and pattern not found: 0 seconds
  • if head is 4000 and pattern found: 0 seconds
Returns:str
pytan3.adapters.serialize_xml(obj, **kwargs)[source]

Encode python object into an XML string.

Parameters:
  • obj (object) – Python object to encode into a string.
  • **kwargs
    full_document (bool):
    Include xml stanza at top.

    Defaults to: True.

    pretty (bool):
    Indent the output doc.

    Defaults to: True.

    rest of kwargs:
    Passed to xmltodict.unparse.
Returns:

str