Parser

class Parser[source]

Bases: object

A collection of static methods used by the pyasdm classes in producing and consuming XML. This is different from how the strongly typed languages use Parser, but it’s similar enough that it’s been kept in a class of the same name. This is not generated code.

Methods Summary

extendedValueToXML(name, value)

Return a string of the form ‘<name> value </name>’ to be used in the XML output.

listEnumValueToXML(name, value)

Return a string of the form ‘<name> list values </name>’ to be used in the XML output.

listEnumValuesAsString(theList, dims)

Turns a list (including a list of lists as used here) into a string for use in an XML output.

listExtendedValueToXML(name, value)

Return a string of the form ‘<name> list values </name>’ to be used in the XML output.

listExtendedValuesAsString(theList, dims)

Turns a list (including a list of lists as used here) into a string for use in an XML output.

listValueToXML(name, value)

Return a string of the form ‘<name> list values </name>’ to be used in the XML output.

listValuesAsString(theList, dims)

Turns a list (including a list of lists as used here) into a string for use in an XML output.

listXMLPrefix(dims)

Return a string with the dimensions list encoded as expected for XML storage of the associated list.

nameStringToXML(name, strval)

A method to produce XML using the name and a string value.

splitStrToClassLists(splitStr, dims, ListClass)

splitStrToExtendedClassLists(splitStr, dims, …)

stringListToLists(strlist, ListClass, …)

Parse an array expessed in strlist into a list (including lists of list) made up of elements of ListClass that can all be constructed from strings in that list.

valueToXML(name, value)

Return a string of the form ‘<name> value </name>’ to be used in the XML output.

Methods Documentation

static extendedValueToXML(name, value)[source]

Return a string of the form ‘<name> value </name>’ to be used in the XML output. The value must have a __str__ member used to convert that value to a string representation. Extended type values all have that function.

ArrayTimeInterval is the exception. The __str__ method there is not used here following the similar case Java.

static listEnumValueToXML(name, value)[source]

Return a string of the form ‘<name> list values </name>’ to be used in the XML output. The list values are encoded such that they can be read and the list (which may be a list of lists, i.e. an ND array of values) be fully reconstructed from that XML. For use with enumeration which can be expressed as a string using their name() member function. Arrays are encoded here as <name> ndim dim1 dim2 dim… dimn value value value … </name> and the most rapidly varying dimension among the values is the last dimension.

static listEnumValuesAsString(theList, dims)[source]

Turns a list (including a list of lists as used here) into a string for use in an XML output. Values in the list are Enumerations and are turned into a string by use of the getName method.

static listExtendedValueToXML(name, value)[source]

Return a string of the form ‘<name> list values </name>’ to be used in the XML output. The list values are encoded such that they can be read and the list (which may be a list of lists, i.e. an ND array of values) be fully reconstructed from that XML. For use with extended types which can be expressed as a string using their __str__ member function. Arrays are encoded here as <name> ndim dim1 dim2 dim… dimn value value value … </name> and the most rapidly varying dimension among the values is the last dimension.

static listExtendedValuesAsString(theList, dims)[source]

Turns a list (including a list of lists as used here) into a string for use in an XML output. Values in the list are extended type values and are turned into a string by use of the __str__ method that is part of extended types.

static listValueToXML(name, value)[source]

Return a string of the form ‘<name> list values </name>’ to be used in the XML output. The list values are encoded such that they can be read and the list (which may be a list of lists, i.e. an ND array of values) be fully reconstructed from that XML. For use with standard types which can be expressed as a string using str(value). Arrays are encoded here as <name> ndim dim1 dim2 dim… dimn value value value … </name> and the most rapidly varying dimension among the values is the last dimension.

static listValuesAsString(theList, dims)[source]

Turns a list (including a list of lists as used here) into a string for use in an XML output. Values in the list are turned into a string by use of str(value).

static listXMLPrefix(dims)[source]

Return a string with the dimensions list encoded as expected for XML storage of the associated list. ‘no_dims dim0 dim1 … dimn ‘

static nameStringToXML(name, strval)[source]

A method to produce XML using the name and a string value. <name>strval</name> The returned value has a trailing space so that it can be used to add these strings together without worrying about spacing.

static splitStrToClassLists(splitStr, dims, ListClass)[source]
static splitStrToExtendedClassLists(splitStr, dims, ListClass)[source]
static stringListToLists(strlist, ListClass, tableName, isExtendedType)[source]

Parse an array expessed in strlist into a list (including lists of list) made up of elements of ListClass that can all be constructed from strings in that list. Some extended type instances use more than one element. When isExtendedType is True then the appropriate function to extra extended type values is used. The tableName is used when raising ConversionException to indicate the responsible table.

static valueToXML(name, value)[source]

Return a string of the form ‘<name> value </name>’ to be used in the XML output. The value must be convertable to a string using the simple str(value) method. A value that is an instance of a class with a __str__ method should use the extendedValuetoXML method.