schematics_xml package

Submodules

schematics_xml.models module

schematics_xml.models

Base models that provide to/from XML methods.

class schematics_xml.models.XMLModel(raw_data=None, trusted_data=None, deserialize_mapping=None, init=True, partial=True, strict=True, validate=False, app_data=None, **kwargs)[source]

Bases: schematics.models.Model

A model that can convert it’s fields to and from XML.

classmethod from_xml(xml: str) → schematics.models.Model[source]

Convert XML into a model.

Parameters:xml – A string of XML that represents this Model.
primitive_to_xml(primitive: dict, parent: typing.Union[lxml.etree._Element, NoneType] = None)[source]
primitive_value_to_xml(key, parent, value)[source]
to_xml(*, role: str = None, app_data: dict = None, **kwargs) → str[source]

Return a string of XML that represents this model.

Currently all arguments are passed through to schematics.Model.to_primitive.

Parameters:
  • role – schematics Model to_primitive role parameter.
  • app_data – schematics Model to_primitive app_data parameter.
  • kwargs – schematics Model to_primitive kwargs parameter.
xml_root
schematics_xml.models.field_has_type(needle: schematics.types.base.BaseType, field: schematics.types.base.BaseType) → bool[source]

Return True if field haystack contains a field of type needle.

Parameters:
  • needle – A schematics field class to search for.
  • haystack – An instance of a schematics field within a model.
schematics_xml.models.model_has_field_type(needle: schematics.types.base.BaseType, haystack: schematics.models.Model) → bool[source]

Return True if haystack contains a field of type needle.

Iterates over all fields (and into field if appropriate) and searches for field type needle in model haystack.

Parameters:
  • needle – A schematics field class to search for.
  • haystack – A schematics model to search within.

Module contents

Python schematics models for converting to and from XML.

class schematics_xml.VersionInfo(major, minor, micro, releaselevel, serial)

Bases: tuple

major

Alias for field number 0

micro

Alias for field number 2

minor

Alias for field number 1

releaselevel

Alias for field number 3

serial

Alias for field number 4