schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes module¶
This module contains XSD types classes for xsdtypes package
-
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
is_datetime
(date_string, date_format='%Y-%m-%d')¶ Check if the string represents a valid datetime according to the specified formatting.
Parameters: - date_string – The string containing the datetime
- date_format – The reference formatting for datetime
Returns: True if the string is a valid datetime, False if not.
-
class
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
XSDType
(name, python_type, validators=None, to_python=None, from_python=<class '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)-
__init__
(name, python_type, validators=None, to_python=None, from_python=<class 'str'>)¶ Parameters: - python_type – The correspondent Python’s type
- validators – The optional validator for value objects
- to_python – The optional decode function
- from_python – The optional encode function
-
is_list
()¶
-
validate
(value)¶ Validator for decoded values. :param value: The Python’s object that has to be validated
-
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
-
basename
()¶ Get the name of the type without prefix or namespace URI.
-
get_rank
()¶ The rank of the XSDType-only instance (an XSD builtin type) is always 0.
-
get_lengths
(only_lists=True)¶
-
-
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.
-
__init__
(base_type, elem, name=None, is_list=False, length=None, validators=None, enumeration=None)¶ Parameters: - python_type – The correspondent Python’s type
- validators – The optional validator for value objects
- to_python – The optional decode function
- from_python – The optional encode function
-
is_list
()¶
-
validate
(value)¶ Validator for decoded values. :param value: The Python’s object that has to be validated
-
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_rank
()¶ Compute the pseudo-dimension of the XSDSimpleType, considering the dimension of the base type.
Returns: int
-
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
-
basename
()¶ Get the name of the type without prefix or namespace URI.
-
-
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.
-
__init__
(base_type, elem, name=None, is_list=False, validators=None, enumeration=None, content_model=None, attributes=None)¶ Parameters: - python_type – The correspondent Python’s type
- validators – The optional validator for value objects
- to_python – The optional decode function
- from_python – The optional encode function
-
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 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)¶ Validator for decoded values. :param value: The Python’s object that has to be validated
-
-
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.
-
__init__
(name, path, xsd_type, attrib=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
name
= None¶ The name is the element tag
-
path
= None¶ The XPath of this element
-
xsd_type
= None¶ XSD type of the element
-
attrib
= None¶ Attributes of element declaration (eg. minOccurs, default …)
-
basename
()¶ Get the name of the element without prefix or namespace URI.
-
get_type
()¶
-
is_optional
()¶
-
get_default
()¶
-
get_min_occurs
()¶
-
get_max_occurs
()¶
-
-
class
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
XSDAttribute
(xsd_type, attrib=None)¶ Bases:
object
Support structure to associate an attribute with XSD simple types.
-
__init__
(xsd_type, attrib=None)¶ Initialize self. See help(type(self)) for accurate signature.
-
xsd_type
= None¶ XSD type of the attribute
-
attrib
= None¶ Attributes of attribute declaration (eg. use, default, …)
-
get_type
()¶
-
is_optional
()¶
-
get_default
()¶
-
-
class
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
XSDGroup
(name=None, group_type=None, attrib=None, *args, **kwargs)¶ Bases:
list
-
__init__
(name=None, group_type=None, attrib=None, *args, **kwargs)¶ Initialize self. See help(type(self)) for accurate signature.
-
attrib
= None¶ Attributes of element declaration (eg. minOccurs, default …)
-
get_min_occurs
()¶
-
get_max_occurs
()¶
-
__contains__
¶ Return key in self.
-
__len__
¶ Return len(self).
-
append
(object) → None -- append object to end¶
-
clear
() → None -- remove all items from L¶
-
copy
() → list -- a shallow copy of L¶
-
count
(value) → integer -- return number of occurrences of value¶
-
extend
(iterable) → None -- extend list by appending elements from the iterable¶
-
index
(value[, start[, stop]]) → integer -- return first index of value.¶ Raises ValueError if the value is not present.
-
insert
()¶ L.insert(index, object) – insert object before index
-
pop
([index]) → item -- remove and return item at index (default last).¶ Raises IndexError if list is empty or index is out of range.
-
remove
(value) → None -- remove first occurrence of value.¶ Raises ValueError if the value is not present.
-
reverse
()¶ L.reverse() – reverse IN PLACE
-
sort
(key=None, reverse=False) → None -- stable sort *IN PLACE*¶
-
-
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
xsd_builtin_types_factory
(xsd_type_class=<class 'schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType'>, *args, **kwargs)¶ Build a dictionary for XSD builtin types mapping.
Parameters: - xsd_type_class – XSDType class for instances.
- args – List of tuples containing a single definition.
- kwargs – A dictionary with multiple built-in type declarations.
Returns: Dictionary that map a type name to a decoding type class instance
-
schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.
XSD_BUILTIN_TYPES
= {'QName': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'anyType': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'anyURI': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'boolean': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'byte': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'date': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'dateTime': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'decimal': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'double': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'duration': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'float': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gDay': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gMonth': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gMonthDay': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gYear': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'gYearMonth': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'int': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'integer': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'long': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'negativeInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'nonNegativeInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'nonPositiveInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'positiveInteger': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'short': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'string': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'time': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedByte': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedInt': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedLong': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDType object>, 'unsignedShort': <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.
XSI_ATTRIBUTES
= {'{http://www.w3.org/2001/XMLSchema-instance}noNamespaceSchemaLocation': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDAttribute object>, '{http://www.w3.org/2001/XMLSchema-instance}schemaLocation': <schrodinger.application.matsci.qexsd.qespresso.xsdtypes.xsdtypes.XSDAttribute object>}¶ XSI attributes for schema instances
-
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_group_factory
(elem, **kwargs)¶
-
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.
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.
-
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