コード例 #1
0
 def run(self, inputIn):
   """
     This method executes the postprocessor action.
     @ In, inputIn, dict, dictionary of data to process
     @ Out, outputDict, dict, dictionary containing the post-processed results
   """
   # outputs are realizations that will got into data object
   outputDict={'realizations':[]}
   if self.dynamic:
     #outputs are basically a point set with pivot as input and requested XML path entries as output
     fileName = self.files.values()[0]['fileObject'].getAbsFile()
     root,_ = xmlUtils.loadToTree(fileName)
     #determine the pivot parameter
     pivot = root[0].tag
     numPivotSteps = len(root)
     #read from each iterative pivot step
     for p,pivotStep in enumerate(root):
       realization = {'inputs':{},'outputs':{},'metadata':{'loadedFromRavenFile':fileName}}
       realization['inputs'][pivot] = float(pivotStep.attrib['value'])
       for name,path in self.files.values()[0]['paths'].items():
         desiredNode = self._readPath(pivotStep,path,fileName)
         realization['outputs'][name] = float(desiredNode.text)
       outputDict['realizations'].append(realization)
   else:
     # each ID results in a realization for the requested attributes
     for id,fileDict in self.files.items():
       realization = {'inputs':{'ID':id},'outputs':{},'metadata':{'loadedFromRavenFile':str(fileDict['fileObject'])}}
       for varName,path in fileDict['paths'].items():
         #read the value from the file's XML
         root,_ = xmlUtils.loadToTree(fileDict['fileObject'].getAbsFile())
         desiredNode = self._readPath(root,path,fileDict['fileObject'].getAbsFile())
         realization['outputs'][varName] = float(desiredNode.text)
       outputDict['realizations'].append(realization)
   return outputDict
コード例 #2
0
ファイル: template_driver.py プロジェクト: wanghy-anl/HERON
    def loadTemplate(self, filename, path):
        """ todo """
        rel_path = os.path.join(self._template_path, path)
        self._template_inner_path = os.path.join(rel_path, 'inner.xml')
        self._template_outer_path = os.path.join(rel_path, 'outer.xml')
        self._template_cash_path = os.path.join(rel_path, 'cash.xml')

        self._template_inner, _ = xmlUtils.loadToTree(
            self._template_inner_path, preserveComments=True)
        self._template_outer, _ = xmlUtils.loadToTree(
            self._template_outer_path, preserveComments=True)
        self._template_cash, _ = xmlUtils.loadToTree(self._template_cash_path,
                                                     preserveComments=True)
コード例 #3
0
ファイル: input_loader.py プロジェクト: wanghy-anl/HERON
def load(name):
    """
    Loads file into XML format
    @ In, name, str, name of file to read from
    @ Out, xml, ET.element, input as xml
  """
    xml, _ = xmlUtils.loadToTree(name)
    return xml
コード例 #4
0
 def loadTemplate(self, filename, path):
     """
   Loads template file statefully.
   @ In, filename, str, name of file to load (xml)
   @ In, path, str, path (maybe relative) to file
   @ Out, None
 """
     # TODO what should "path" be relative to? I vote the Template file.
     relPath = os.path.join(self._templatePath, path)
     templateFile = os.path.join(os.path.normpath(relPath), filename)
     self._template, _ = xmlUtils.loadToTree(templateFile)
コード例 #5
0
def loadPlugins(path, catalogue):
    """
    Loads plugins and their entities into factory storage.
    @ In, path, str, location of plugins folder
    @ In, catalogue, str, location of plugins directory xml file
    @ Out, None
  """
    pluginsRoot, _ = xmlUtils.loadToTree(catalogue)
    for pluginNode in pluginsRoot:
        name = pluginNode.find('name').text
        location = pluginNode.find('location').text
        if location is None:
            raise PluginError(
                'Installation is corrupted for plugin "{}". Check raven/plugins/plugin_directory.xml and try reinstalling using raven/scripts/intall_plugin'
            )
        if name is None:
            name = os.path.basename(location)
        print('Loading plugin "{}" at {}'.format(name, location))
        module = loadPluginModule(name, location)
        loadEntities(name, module)