Exemplo n.º 1
0
 def _parse_xml_content(content: ElementTree) -> [Currency]:
     Logger.i(
         "CurrencyRepository#_parse_xml_content -> Beginning xml parsing")
     currency_list = []
     for item in content.iter():
         time = item.get("time")
         if time is not None:
             for currency_xml_obj in item:
                 currency = Currency()
                 currency_code = currency_xml_obj.get("currency")
                 rate = currency_xml_obj.get("rate")
                 if time is not None:
                     currency.historical_date = time
                 if currency_code is not None:
                     currency.currency_code = currency_code
                 if rate is not None:
                     currency.rate = float(rate)
                 currency.timestamp = datetime.datetime.timestamp(
                     datetime.datetime.now())
                 currency.friendly_name = currency_code
                 currency_list.append(currency)
     Logger.i(
         "CurrencyRepository#_parse_xml_content -> Xml parsing completed")
     return currency_list