schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes module

This module contains XSD types classes for xsdtypes package

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSI_ATTRIBUTES = {'{http://www.w3.org/2001/XMLSchema-instance}schemaLocation': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDAttribute object>, '{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDAttribute object>}

XSI attributes for schema instances

class schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType(name, python_type, validators=None, to_python=None, from_python=<type 'str'>)

Bases: object

Base class for representing generic XSD types. Use this class for create XSD built-in types.

An instance contains a Python’s type transformation ana a list of validator functions.

Use Python’s types conversion:

Decoding from XML: python_type(value) Encoding to XML: str(value)
basename()

Get the name of the type without prefix or namespace URI.

decode(text)

Transform an XML text into a Python object. :param text: XML text

encode(obj)

Transform a Python object into an XML string. :param obj: The Python object that has to be encoded in XML

get_lengths(only_lists=True)
get_rank()

The rank of the XSDType-only instance (an XSD builtin type) is always 0.

is_list()
validate(value)

Validator for decoded values. :param value: The Python’s object that has to be validated

class schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDSimpleType(base_type, elem, name=None, is_list=False, length=None, validators=None, enumeration=None)

Bases: schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType

A class for represent XSD schema simple type.

decode(text)
encode(obj)
get_lengths(only_lists=True)

Get the lengths defined for the XSD type.

Parameters:only_lists – Include lengths defined for other types.
Returns:a list with defined lengths
get_rank()

Compute the pseudo-dimension of the XSDSimpleType, considering the dimension of the base type.

Returns:int
is_list()
validate(value)
class schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDComplexType(base_type, elem, name=None, is_list=False, validators=None, enumeration=None, content_model=None, attributes=None)

Bases: schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDSimpleType

A class for represent XSD schema simple type.

class schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDElement(name, path, xsd_type, attrib=None)

Bases: object

Support structure to associate an element and its attributes with XSD simple types.

attrib = None

Attributes of element declaration (eg. minOccurs, default …)

basename()

Get the name of the element without prefix or namespace URI.

get_default()
get_max_occurs()
get_min_occurs()
get_type()
is_optional()
name = None

The name is the element tag

path = None

The XPath of this element

xsd_type = None

XSD type of the element

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.xsd_simple_type_factory(elem, **kwargs)

Factory function for XSD simple type declaration.

Parameters:elem – The ElementTree’s Element. It must be

a simpleType declaration element. :param kwargs: Various lookup tables and parameters, dependant by the context where the function is called. :return: a couple with the type_name, that maybe an empty string, and the XSDSimpleType instance that represents the XSD declaration.

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.xsd_attribute_type_factory(elem, **kwargs)

Factory function for XSD attribute declaration.

Parameters:elem – The ElementTree’s Element. It must be

a attribute declaration element. :param kwargs: Various lookup tables and parameters, dependant by the context where the function is called. :return: a couple with the attribute name and the instance of XSDType associated with it.

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.xsd_complex_type_factory(elem, **kwargs)

Factory function for XSD complex type declaration.

Parameters:elem – The ElementTree’s Element. It must be

a complexType declaration element. :param kwargs: Various lookup tables and parameters, dependant by the context where the function is called. :return: a couple with the type_name, that maybe an empty string, and the XSDComplexType instance that represents the XSD declaration.

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.xsd_element_factory(elem, xsd_element=None, **kwargs)

Factory function for XSD element declaration. The function walks through complexTypes to find declarations of descendant XSD elements.

Parameters:elem – The ElementTree’s Element. It must be

an element declaration element. :param xsd_element: The complex type, if it’s already created. :param kwargs: Various lookup tables and parameters, dependant by the context where the function is called. An xsd_elements dictionary is needed as the destination of the XSD element declarations.

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSD_BUILTIN_TYPES = {'unsignedInt': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'int': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'float': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'boolean': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'positiveInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'duration': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedLong': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'negativeInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'long': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedShort': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'nonPositiveInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'anyURI': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedByte': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'string': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'date': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'integer': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'byte': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gMonth': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'short': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gMonthDay': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'double': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'decimal': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gDay': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gYearMonth': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'QName': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'dateTime': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'nonNegativeInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gYear': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'time': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'anyType': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>}

Dictionary for XSD built-in types mapping. The values are XSDType instances

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.xsd_get_type(type_name, xsd_types)

Lookup for a XSD type in XSD predefined built-in types map and in XML Schema types map.

Parameters:
  • type_name – XSD type name
  • xsd_types – Map for XSD simple types
Returns:

BaseXSDType/XSDSimpleType instance

schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.add_xsd_types_to_dict(declarations, target_dict, factory_function, **kwargs)

Function to add XSD global types declarations. Unresolved references to other types in the list are retried until are completed.

Parameters:declarations – Sequence of XSD simpleType/complexType

declarations. :param target_dict: Dictionary for type declarations. :param factory_function: Factory function to use. :param kwargs: Various arguments to pass to the factory function.