コード例 #1
0
 def parseXML(self, blockette, xml_doc, pos=0):
     """
     """
     try:
         text = xml_doc.xpath(self.field_name + "/text()")[pos]
     except:
         setattr(blockette, self.attribute_name, self.default_value)
         # debug
         if blockette.debug:
             print('  %s: set to default value %s' % (self,
                                                      self.default_value))
         return
     # Parse X-Path if necessary. The isdigit test assures legacy support
     # for XSEED without XPaths.
     if self.xpath and not text.isdigit():
         text = utils.getXPath(text)
     # check if already exists
     if hasattr(blockette, self.attribute_name):
         temp = getattr(blockette, self.attribute_name)
         if not isinstance(temp, list):
             temp = [temp]
         temp.append(text)
         text = temp
     setattr(blockette, self.attribute_name, self.convert(text))
     # debug
     if blockette.debug:
         print('  %s: %s' % (self, text))
コード例 #2
0
ファイル: blockette060.py プロジェクト: CSchwarz1234/obspy
 def parseXML(self, xml_doc, version='1.0', *args, **kwargs):
     """
     Read XML of blockette 60.
     """
     # Loop over ch
     for child in xml_doc.getchildren():
         if child.tag != 'stage':
             continue
         self.stages.append([])
         for inner_child in child.getchildren():
             if inner_child.tag != 'response_lookup_key':
                 continue
             # for legacy support meaning XSEED without XPaths.:
             if inner_child.text.isdigit():
                 self.stages[-1].append(int(inner_child.text))
             else:
                 self.stages[-1].append(getXPath(inner_child.text))
コード例 #3
0
ファイル: blockette060.py プロジェクト: shineusn/obspy
 def parseXML(self, xml_doc, version='1.0', *args, **kwargs):
     """
     Read XML of blockette 60.
     """
     # Loop over ch
     for child in xml_doc.getchildren():
         if child.tag != 'stage':
             continue
         self.stages.append([])
         for inner_child in child.getchildren():
             if inner_child.tag != 'response_lookup_key':
                 continue
             # for legacy support meaning XSEED without XPaths.:
             if inner_child.text.isdigit():
                 self.stages[-1].append(int(inner_child.text))
             else:
                 self.stages[-1].append(getXPath(inner_child.text))