small refactor for eda xml parser
This commit is contained in:
parent
4fefd017a2
commit
af81cd1da7
@ -28,14 +28,14 @@ class EDAXMLHandler:
|
|||||||
def _line_items(self):
|
def _line_items(self):
|
||||||
return self.element_tree.findall(".//LineItem[LineItemType='CLIN']/../../..")
|
return self.element_tree.findall(".//LineItem[LineItemType='CLIN']/../../..")
|
||||||
|
|
||||||
def _parse_clin_data(self):
|
|
||||||
for line_item in self._line_items:
|
|
||||||
number = line_item.find(".//LineItemBase").text
|
|
||||||
amount_details = line_item.find(".//ItemOtherAmounts[AmountDescription='Not to Exceed Amount (Funding)']/Amount")
|
|
||||||
self.clins[number] = float(amount_details.text)
|
|
||||||
|
|
||||||
def parse(self):
|
def parse(self):
|
||||||
self._parse_clin_data()
|
for line_item in self._line_items:
|
||||||
|
number_el = line_item.find(".//LineItemBase")
|
||||||
|
amount_details = line_item.find(
|
||||||
|
".//ItemOtherAmounts[AmountDescription='Not to Exceed Amount (Funding)']/Amount"
|
||||||
|
)
|
||||||
|
if number_el is not None and amount_details is not None:
|
||||||
|
self.clins[number_el.text] = float(amount_details.text)
|
||||||
|
|
||||||
|
|
||||||
class EDAClientBase(object):
|
class EDAClientBase(object):
|
||||||
|
@ -22,5 +22,5 @@ def test_contract_not_found():
|
|||||||
def test_eda_xml_parser():
|
def test_eda_xml_parser():
|
||||||
with open("tests/fixtures/eda_contract.xml") as contract:
|
with open("tests/fixtures/eda_contract.xml") as contract:
|
||||||
eda_data = parse_eda_xml(contract.read())
|
eda_data = parse_eda_xml(contract.read())
|
||||||
assert eda_data["clin_0001"] == 200000.00
|
assert eda_data["clin_0001"] == 200_000.00
|
||||||
assert not eda_data["clin_0003"]
|
assert not eda_data["clin_0003"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user