dtdGenerator — Generates the ADMIT DTD files.¶
This module defines the DTD generator for ADMIT. The DTDs are used to validate the XML I/O.
In addition to generating the DTDs for each AT and BDP, the following files are also created:
- bdp_types.py — constants and types definition file
- __init__.py — in both admit/at and admit/bdp
Usage:
import dtdGenerator
dtdGenerator.generate()
-
class
admit.xmlio.dtdGenerator.DtdGenerator[source]¶ Class to generate the dtd files for ADMIT. The dtd’s are generated by searching for all BDP, AT, and utility class files (those located in admit/util and inherit from UtilBase). Each file is then loaded and introspected, and dtd’s are generated by both the name and the type of each class attribute.
Parameters: None Attributes
util_class (dict) Dictionary containing the utility class types as keys and a class instance as the values. util_string (dict) Dictionary containing the utility class types as keys and the class description for the dtd as the values. util_dtd (dict) Dictionary containing the utility class types as keys and the dtd entries as the values. Methods
generate()Main method for generating the dtd. getType(i, val, key)Method to generate a string version of the data type of the input value. writeEntry(k, v, dtd)Generic method to write out the given class attribute to the dtd. write_at(key, val)Method which takes a class name and AT sub-class instance. write_bdp(key, val)Method which takes a class name and BDP sub-class instance. -
generate()[source]¶ Main method for generating the dtd. Searches through the BDP and AT directories and generates dtds for each file found.
Parameters: None Returns: None
-
getType(i, val, key)[source]¶ Method to generate a string version of the data type of the input value.
Parameters: val : various
The value whose type is to be determined
key : str
The name of the variable that holds the data. Used only to give sensible error messages.
Returns: A string containing the type information
-
writeEntry(k, v, dtd)[source]¶ Generic method to write out the given class attribute to the dtd.
Parameters: k : str
The keyword that is being written out.
v : str
The data type of the keyword (e.g. bt.FLOAT).
dtd : file handle
The handle to the file where the dtd is being written.
-