OSFI-Python  3.10.0
OpenSF Integration Library
OSFI.ParamReader.ParamReader Class Reference

Public Member Functions

def __init__ (self, xmlFile, xsdFile=None)
 
def getParameter (self, paramName)
 
def getParameters (self, groupName)
 
def getAllParameters (self)
 
def existParameter (self, paramName)
 
def setParameter (self, paramName, value)
 
def write (self)
 
def validateAgainst (self, xsdFile)
 
def validateAgainstInternalSchema (self)
 

Detailed Description

This ConFM class parses the XML configuration files provided by the openSF HMI formatted
with the following elements:
- Element <group_name>. This element can create nested groups to enclose parameters and
provide scope information. Optional element.
- Element parameter. This element can define the following attributes:
        - Name. This is the parameter identifier. Names cannot contain spaces
        - Description. Short definition or meaning for the parameter
        - Type. Possible values for this attribute are: INTEGER, DOUBLE, BOOLEAN, STRING,
            FILE or FOLDER. These are system-independent type of values, only intended for
            GUI formatting validations.
        - Value. This is the numerical, string or file location value of the parameter
        - Units. Physical units of measurements if applicable. This attribute is optional
        - Dims. Size of the dimensions. For example 1, 3 is a vector of three elements and
            3, 3 is a square matrix of 3x3 elements. The first number refers to columns
            and the second one to rows when describing a matrix. This attribute is optional
            for scalar variables.
            For variables of vector/matrix types, the value attribute must contain a
            comma-separated (or blank-separated) list of values by rows, following this example:
                A 3 columns by 2 rows matrix (dims = 3,2)
                1    2    3
                4    5    6
            Will be represented as: 1,2,3,4,5,6.
            String vectors must enclose each element in single quotes. For example
            'a string' 'second string' 'third and last string'.

Constructor & Destructor Documentation

◆ __init__()

def OSFI.ParamReader.ParamReader.__init__ (   self,
  xmlFile,
  xsdFile = None 
)
Default class constructor.
Creates an instance of the ParamReader class, parses a given configuration XML file and
stores every valid parameter.</p>
<p>Validating against an XSD schema is optional.</p>
@param xmlFile - Configuration XML file
@param xsdFile - IGNORED, will generate a deprecation warning
@throw exception if error while parsing

References OSFI.ParamReader.ParamReader.__root, OSFI.ParamReader.ParamReader.__traverseNodes(), and OSFI.ParamReader.ParamReader.__tree.

Member Function Documentation

◆ existParameter()

def OSFI.ParamReader.ParamReader.existParameter (   self,
  paramName 
)
Checks the existence of a parameter within a configuration file.
@param paramName Parameter name (full path and name)
@return boolean True if the parameter exists False otherwise.

◆ getAllParameters()

def OSFI.ParamReader.ParamReader.getAllParameters (   self)
Gets a map containing all stored parameters.

◆ getParameter()

def OSFI.ParamReader.ParamReader.getParameter (   self,
  paramName 
)
Gets the parameter object with the given full path in the configuration file.
@param paramName Parameter name (full path and name)
@return .Parameter instance.

◆ getParameters()

def OSFI.ParamReader.ParamReader.getParameters (   self,
  groupName 
)
Gets the list of parameters under a certain group.
@param groupName - full name of the group.

◆ setParameter()

def OSFI.ParamReader.ParamReader.setParameter (   self,
  paramName,
  value 
)
Changes the stored value of a certain parameter.
Shows an error if cannot find parameter.
@param paramName - full name of the parameter
@param value - new value
@throw exception if value is invalid

◆ validateAgainst()

def OSFI.ParamReader.ParamReader.validateAgainst (   self,
  xsdFile 
)
Validate the XML document read against the given schema, logging problems found.
@return True if validation succeds, False otherwise.
@throw Exception If the named schema cannot be loaded
@throw NotImplementedError If the ElementTree library does not implement XSD validation

References OSFI.ParamReader.ParamReader.__doValidate().

◆ validateAgainstInternalSchema()

def OSFI.ParamReader.ParamReader.validateAgainstInternalSchema (   self)
Validate the XML document read against the schema linked in the document itself, logging
any problems found.
@return True if validation succeds, False otherwise.
@throw ValueError If the document does not link to a XSD schema using the "schemaLocation"
    or "noNamespaceSchemaLocation" attributes from the
    "http://www.w3.org/2001/XMLSchema-instance" namespace.
@throw Exception If the linked schema cannot be loaded
@throw NotImplementedError If the ElementTree library does not implement XSD validation

References OSFI.ParamReader.ParamReader.__doValidate(), and OSFI.ParamReader.ParamReader.__root.

◆ write()

def OSFI.ParamReader.ParamReader.write (   self)
Prints a textual representation of the list of Parameters on screen.

References OSFI.ParamReader.ParamReader.__readParameter(), OSFI.ParamReader.ParamReader.__traverseNodes(), and OSFI.ParamReader.ParamReader.__tree.


The documentation for this class was generated from the following file: