Archived
1
0

made get_unit function

This commit is contained in:
RTB 2014-06-10 13:13:24 +02:00
parent 7879d523ec
commit a15a66cc77

View File

@ -201,11 +201,7 @@ class NIST(Source):
""" """
results = [] results = []
tr_unit = ''.join(table.xpath('tr[1]/th[1]/node()').extract()) unit = self.get_unit(table)
m = re.search(r'\((.*)\)', tr_unit)
unit = '!'
if m:
unit = m.group(1)
for tr in table.xpath('tr[td]'): for tr in table.xpath('tr[td]'):
tds = tr.xpath('td/text()').extract() tds = tr.xpath('td/text()').extract()
@ -230,11 +226,7 @@ class NIST(Source):
""" """
results = [] results = []
tr_unit = ''.join(table.xpath('tr[1]/th[1]/node()').extract()) unit = self.get_unit(table)
m = re.search(r'\((.*)\)', tr_unit)
unit = '!'
if m:
unit = m.group(1)
for tr in table.xpath('tr[td]'): for tr in table.xpath('tr[td]'):
tds = tr.xpath('td/text()').extract() tds = tr.xpath('td/text()').extract()
@ -286,11 +278,7 @@ class NIST(Source):
name = m.group(1) name = m.group(1)
condition = m.group(2) condition = m.group(2)
tr_unit = ''.join(table.xpath('tr[1]/th[1]/node()').extract()) unit = self.get_unit(table)
m = re.search(r'\((.*)\)', tr_unit)
unit = '!'
if m:
unit = m.group(1)
for tr in table.xpath('tr[td]'): for tr in table.xpath('tr[td]'):
tds = tr.xpath('td/text()').extract() tds = tr.xpath('td/text()').extract()
@ -308,6 +296,16 @@ class NIST(Source):
return results return results
@staticmethod
def get_unit(table):
tr_unit = ''.join(table.xpath('tr[1]/th[1]/node()').extract())
m = re.search(r'\((.*)\)', tr_unit)
unit = '!'
if m:
unit = m.group(1)
return unit
def newresult(self, attribute, value, conditions=''): def newresult(self, attribute, value, conditions=''):
""" """
This function abstracts from the Result item and provides default This function abstracts from the Result item and provides default