示例#1
0
 def __init__(self, path=None, root_name='result', read_only=False):
     if path == None:
         self.path = path
         self.root = xmlTree.Element(root_name)
         self.tree = xmlTree.ElementTree(self.root)
     else:
         self.path = path
         self.tree = toolbox_basic.get_xml_tree(self.path)
         self.root = self.tree.getroot()
     self.path = path
     self.tree = toolbox_basic.get_xml_tree(self.path)
     if self.tree == None:
         self.root = xmlTree.Element(root_name)
         self.tree = xmlTree.ElementTree(self.root)
     else:
         self.root = self.tree.getroot()
     self.read_only = read_only
     self.header = ''
     try:
         if 'header' in self.root.attrib.keys():
             self.header = self.root.attrib['header']
     except AttributeError:
         pass
     self.lines = []
     self.subresults = []
    def find_protocol_file_xml_tree(self, filename=None):
        """

        """
        if filename is None:
            filename = toolbox_basic.find_protocol_file_path(self.path)
        self.protocol_file_xml_tree = toolbox_basic.get_xml_tree(filename)
示例#3
0
 def __init__(self, root_dir, find_protocol=True):
     self.root_dir = toolbox_basic.check_path(root_dir)
     if not find_protocol: return
     # Set up the space from the protocol file.
     protocol_path = toolbox_basic.find_protocol_file_path(self.root_dir)
     self.protocol_tree = toolbox_basic.get_xml_tree(protocol_path)
     space_params = self.protocol_tree.findall('./space/param')
     for param in space_params:
         name, text = param.attrib['name'], param.text
         if name == 'wrapping': self.wrapping = (text == 'true')
         elif name == 'length': self.side_length = int(float(text))
         elif name == 'nDims':  self.is_3d = (int(float(text)) == 3)
     marks = self.protocol_tree.findall('./mark')
     for mark in marks:
         for param in mark:
             if param.attrib['name'] == 'value':
                 value = int(param.text)
             if param.attrib['name'] == 'number':
                 number = int(param.text)
         if value == 2:
             self.consumers = number
         else:
             self.producers = number
     rs = self.protocol_tree.find("./process/param[@name='randomSeed']")
     self.random_seed = int(rs.text)
 def __init__(self, path=None, root_name='result', read_only=False):
     if path == None:
         self.path = path
         self.root = xmlTree.Element(root_name)
         self.tree = xmlTree.ElementTree(self.root)
     else:
         self.path = path
         self.tree = toolbox_basic.get_xml_tree(self.path)
         self.root = self.tree.getroot()
     self.path = path
     self.tree = toolbox_basic.get_xml_tree(self.path)
     if self.tree == None:
         self.root = xmlTree.Element(root_name)
         self.tree = xmlTree.ElementTree(self.root)
     else:
         self.root = self.tree.getroot()
     self.read_only = read_only
     self.header = ''
     try:
         if 'header' in self.root.attrib.keys():
             self.header = self.root.attrib['header']
     except AttributeError: pass
     self.lines = []
     self.subresults = []
示例#5
0
 def __init__(self, path=None, root_name='idynomics'):
     if path == None or not os.path.isfile(path):
         self.path = path
         self.root = xmlTree.Element(root_name)
         self.tree = xmlTree.ElementTree(self.root)
         simulation = xmlTree.SubElement(self.root, 'simulation')
         simulation.set('iterate', '0')
         simulation.set('time', '0.0')
         simulation.set('unit', 'h')
     else:
         self.path = toolbox_basic.check_path(path)
         self.tree = toolbox_basic.get_xml_tree(self.path)
         self.root = self.tree.getroot()
     self.simulation = self.find('./simulation')
     self.iterate = int(self.simulation.attrib['iterate'])
     self.time = float(self.simulation.attrib['time'])
     self.time_unit = self.simulation.attrib['unit']