def _xml_to_dict(self, stream):
"""
Reads the locally saved xml file and converts to a Python
dictionary.
"""
print('[%%] Parsing catalogue to Dict')
catalog = defaultdict(dict)
for event, symbol in ET.iterparse(XML_FILE):
if symbol.tag == 'symbol':
if symbol.get('price-stream') == stream:
main_key = symbol.get('name')
values = symbol.attrib
catalog[main_key]['attribs'] = values
catalog[main_key]['time-frames'] = {}
child = symbol.getchildren()[0]
for tf in child.findall('timeframe'):
time_frame = tf.get('name')
v = tf.attrib
catalog[main_key]['time-frames'][time_frame] = v
#symbol.clear()
return dict(catalog)
评论列表
文章目录