utils: Move the xmlinc tool into libs. Signed-off-by: Tim 'mithro' Ansell <me@mith.ro>
diff --git a/vlog_to_model.py b/vlog_to_model.py index 4ab3fdf..6fd12c3 100755 --- a/vlog_to_model.py +++ b/vlog_to_model.py
@@ -23,7 +23,9 @@ import yosys.run from yosys.json import YosysJSON -import xmlinc + +sys.path.insert(0, "..") +from lib import xmlinc def is_clock_assoc(infiles, module, clk, port, direction):
diff --git a/vlog_to_pbtype.py b/vlog_to_pbtype.py index 5c33ece..6769586 100755 --- a/vlog_to_pbtype.py +++ b/vlog_to_pbtype.py
@@ -51,7 +51,9 @@ import yosys.run from yosys.json import YosysJSON -import xmlinc + +sys.path.insert(0, "..") +from lib import xmlinc parser = argparse.ArgumentParser( description=__doc__.strip(), formatter_class=argparse.RawTextHelpFormatter
diff --git a/xmlinc.py b/xmlinc.py deleted file mode 100644 index b611534..0000000 --- a/xmlinc.py +++ /dev/null
@@ -1,32 +0,0 @@ -#!/usr/bin/env python3 -import lxml.etree as ET -import os - -xi_url = "http://www.w3.org/2001/XInclude" - -xi_include = "{{{}}}include".format(xi_url) - -ET.register_namespace('xi', xi_url) - - -def make_relhref(outfile, href): - outpath = os.path.dirname(os.path.abspath(outfile)) - relpath = os.path.relpath(os.path.dirname(os.path.abspath(href)), outpath) - return os.path.join(relpath, os.path.basename(href)) - - -def include_xml(parent, href, outfile, xptr=None): - """ - Generate an XML include, using a relative path. - - Inputs - ------ - parent : XML element to insert include into - href : path to included file - outfile : path to output file, for relative path generation - xptr : optional value for xpointer attribute - """ - xattrs = {'href': make_relhref(outfile, href)} - if xptr is not None: - xattrs["xpointer"] = xptr - return ET.SubElement(parent, xi_include, xattrs)