small refactor for eda xml parser

This commit is contained in:
dandds 2018-10-17 16:31:44 -04:00
parent 4fefd017a2
commit af81cd1da7
2 changed files with 8 additions and 8 deletions

View File

@ -28,14 +28,14 @@ class EDAXMLHandler:
def _line_items(self):
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):
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):

View File

@ -22,5 +22,5 @@ def test_contract_not_found():
def test_eda_xml_parser():
with open("tests/fixtures/eda_contract.xml") as contract:
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"]