Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
2
Merge Requests
2
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
74e10586
Commit
74e10586
authored
Mar 10, 2023
by
Tristan Gingold
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'tl-xci-rework' into 'master'
Fixes for XCI parsing in Python 3.6 See merge request
!23
parents
3b813182
953d32b0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
xci_parser.py
hdlmake/sourcefiles/xci_parser.py
+9
-9
No files found.
hdlmake/sourcefiles/xci_parser.py
View file @
74e10586
...
...
@@ -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
=
f
.
read
()
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
.
load
s
(
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
,
f
ile
):
"""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
.
seek
(
0
)
f
=
file
.
read
()
c
=
f
.
splitlines
()[
0
]
.
strip
()[
0
]
if
c
==
"<"
:
logging
.
debug
(
"Parsing xci as xml format"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment