FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 4663347b authored by Mark Driver's avatar Mark Driver
Browse files

doc updates.

parent 40b39d25
No related branches found
No related tags found
No related merge requests found
...@@ -32,6 +32,25 @@ LOGGER.setLevel(logging.WARN) ...@@ -32,6 +32,25 @@ LOGGER.setLevel(logging.WARN)
class OutputInformation(object): class OutputInformation(object):
"""Class representation of output information.""" """Class representation of output information."""
def __init__(self, fgip_output, similarity_output, similarity_output_type, vle_output): def __init__(self, fgip_output, similarity_output, similarity_output_type, vle_output):
"""Initialise OutputInformation.
Parameters
----------
fgip_output : bool
FGIP output result.
similarity_output : bool
Similarity output result.
similarity_output_type : str
Output type, see schema for restriction.
vle_output : bool
VLE output result.
Returns
-------
OutputInformation
Initialise new OutputInformation.
"""
self.fgip_output = fgip_output self.fgip_output = fgip_output
self.similarity_output = similarity_output self.similarity_output = similarity_output
self.similarity_output_type = similarity_output_type self.similarity_output_type = similarity_output_type
...@@ -58,17 +77,58 @@ class OutputInformation(object): ...@@ -58,17 +77,58 @@ class OutputInformation(object):
return False return False
@classmethod @classmethod
def parse_xml(cls, output_xml): def parse_xml(cls, output_xml):
"""Parse XML representation.
Parameters
----------
output_xml : etree.Element
OutputInformation element representation.
Returns
-------
OutputInformation
New class instance.
"""
fgip_output = OutputInformation.parse_fgip_output(output_xml) fgip_output = OutputInformation.parse_fgip_output(output_xml)
similarity_output, similarity_output_type = OutputInformation.parse_similarity_output(output_xml) similarity_output, similarity_output_type = OutputInformation.parse_similarity_output(output_xml)
vle_output = OutputInformation.parse_vle_output(output_xml) vle_output = OutputInformation.parse_vle_output(output_xml)
return OutputInformation(fgip_output, similarity_output, similarity_output_type, vle_output) return OutputInformation(fgip_output, similarity_output, similarity_output_type, vle_output)
@classmethod @classmethod
def parse_fgip_output(cls, output_xml): def parse_fgip_output(cls, output_xml):
"""Parse FGIP output information from from output information element.
Parameters
----------
output_xml : etree.Element
OutputInformation element representation.
Returns
-------
bool
FGIP output result.
"""
xpath_expression = "phasecalc:FGIPOutput/text()" xpath_expression = "phasecalc:FGIPOutput/text()"
fgip_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0] fgip_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0]
return True if fgip_output == "true" else False return True if fgip_output == "true" else False
@classmethod @classmethod
def parse_similarity_output(cls, output_xml): def parse_similarity_output(cls, output_xml):
"""Parse similarity output information from output information element.
Parameters
----------
output_xml : etree.Element
OutputInformation element representation.
Returns
-------
similarity_output : bool
Similarity output result.
similarity_output_type : str
Output type, see schema for restriction.
"""
xpath_expression = "phasecalc:SimilarityOutput/text()" xpath_expression = "phasecalc:SimilarityOutput/text()"
similarity_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0] similarity_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0]
if similarity_output: if similarity_output:
...@@ -80,6 +140,19 @@ class OutputInformation(object): ...@@ -80,6 +140,19 @@ class OutputInformation(object):
return similarity_output, similarity_output_type return similarity_output, similarity_output_type
@classmethod @classmethod
def parse_vle_output(cls, output_xml): def parse_vle_output(cls, output_xml):
"""Parse VLE from output information element.
Parameters
----------
output_xml : etree.Element
OutputInformation element representation.
Returns
-------
bool
VLE output option.
"""
xpath_expression = "phasecalc:FGIPOutput/text()" xpath_expression = "phasecalc:FGIPOutput/text()"
vle_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0] vle_output = output_xml.xpath(xpath_expression, namespaces=PHASE_CALC_NAMESPACE_DICT)[0]
return True if vle_output == "true" else False return True if vle_output == "true" else False
...@@ -98,16 +171,40 @@ class OutputInformation(object): ...@@ -98,16 +171,40 @@ class OutputInformation(object):
out_element.append(self.write_vle_output()) out_element.append(self.write_vle_output())
return out_element return out_element
def write_fgip_output(self): def write_fgip_output(self):
"""Write FGIP output XML Element.
Returns
-------
fgip_element : etree.Element
FGIP element representation.
"""
fgip_element = etree.Element(PHASE_CALCULATOR + "FGIPOutput", nsmap=PHASE_CALC_NAMESPACE_DICT) fgip_element = etree.Element(PHASE_CALCULATOR + "FGIPOutput", nsmap=PHASE_CALC_NAMESPACE_DICT)
fgip_element.text = str(self.fgip_output).lower() fgip_element.text = str(self.fgip_output).lower()
return fgip_element return fgip_element
def write_similarity_output(self): def write_similarity_output(self):
"""Write Similarity output XML Element.
Returns
-------
sim_element : etree.Element
Similarity element representation.
"""
sim_element = etree.Element(PHASE_CALCULATOR + "SimilarityOutput", nsmap=PHASE_CALC_NAMESPACE_DICT) sim_element = etree.Element(PHASE_CALCULATOR + "SimilarityOutput", nsmap=PHASE_CALC_NAMESPACE_DICT)
sim_element.text = str(self.similarity_output).lower() sim_element.text = str(self.similarity_output).lower()
if self.similarity_output_type is not None: if self.similarity_output_type is not None:
sim_element.set(PHASE_CALCULATOR + "outputType", self.similarity_output_type) sim_element.set(PHASE_CALCULATOR + "outputType", self.similarity_output_type)
return sim_element return sim_element
def write_vle_output(self): def write_vle_output(self):
"""Write VLE output XML Element.
Returns
-------
vle_element : etree.Element
VLE element representation.
"""
vle_element = etree.Element(PHASE_CALCULATOR + "VLEOutput", nsmap=PHASE_CALC_NAMESPACE_DICT) vle_element = etree.Element(PHASE_CALCULATOR + "VLEOutput", nsmap=PHASE_CALC_NAMESPACE_DICT)
vle_element.text = str(self.vle_output).lower() vle_element.text = str(self.vle_output).lower()
return vle_element return vle_element
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment