Commit 953d32b0 authored by Tom Levens's avatar Tom Levens

Fixes for Python 3.6

parent ab2e5ca0
......@@ -40,27 +40,26 @@ class XCIParserBase(DepParser):
def __init__(self, dep_file):
DepParser.__init__(self, dep_file)
def _parse_xml_xci(self, f):
def _parse_xml_xci(self, xml_str):
"""Parse a Xilinx XCI IP description file in XML format"""
# extract namespaces with a regex -- not really ideal, but without pulling in
# an external xml lib I can't think of a better way.
xmlnsre = re.compile(r'''\bxmlns:(\w+)\s*=\s*"(\w+://[^"]*)"''', re.MULTILINE)
xml =
nsmap = dict(xmlnsre.findall(xml))
value = ET.fromstring(xml).find('spirit:componentInstances/spirit:componentInstance/spirit:instanceName', nsmap)
nsmap = dict(xmlnsre.findall(xml_str))
value = ET.fromstring(xml_str).find('spirit:componentInstances/spirit:componentInstance/spirit:instanceName', nsmap)
if not value is None:
return value.text
def _parse_json_xci(self, f):
def _parse_json_xci(self, json_str):
"""Parse a Xilinx XCI IP description file in JSON format"""
data = json.load(f)
data = json.loads(json_str)
ip_inst = data.get('ip_inst')
if ip_inst is not None:
return ip_inst.get('xci_name')
def _parse_xci(self, dep_file, f):
def _parse_xci(self, dep_file, file):
"""Parse a Xilinx XCI IP description file to determine the provided module(s)
This file can either be in XML or JSON file format depending on the
......@@ -75,8 +74,9 @@ class XCIParserBase(DepParser):
# Hacky file format detection, just check the first character of the
# file which should be "<" for XML and "{" for JSON
c = f.readline().strip()[0]
f =
c = f.splitlines()[0].strip()[0]
if c == "<":
logging.debug("Parsing xci as xml format")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment