mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2026-02-17 09:41:19 +01:00
Improve the XML format of Data Model file
This commit is contained in:
parent
5e72e0b978
commit
af33bc4d40
1 changed files with 10 additions and 4 deletions
|
|
@ -8,6 +8,7 @@ import sys
|
|||
import getopt
|
||||
import bbf_common as bbf
|
||||
import xml.etree.ElementTree as ET
|
||||
import xml.dom.minidom as MD
|
||||
|
||||
BBF_REMOTE_DM = None
|
||||
BBF_VENDOR_LIST = None
|
||||
|
|
@ -45,6 +46,11 @@ def print_dmxml_usage():
|
|||
print(" - python " + sys.argv[0] + " -v iopsys,openwrt,test -r https://dev.iopsys.eu/feed/iopsys.git^6.0.0ALPHA1 -p X_TEST_COM_")
|
||||
print(" ==> Generate xml file in %s" % XML_FILE)
|
||||
|
||||
def pretty_format( elem ):
|
||||
elem_string = ET.tostring(elem, 'UTF-8')
|
||||
reparsed = MD.parseString(elem_string)
|
||||
return reparsed.toprettyxml(indent=" ")
|
||||
|
||||
def generate_xml_file():
|
||||
global DM_OBJ_COUNT
|
||||
global DM_PARAM_COUNT
|
||||
|
|
@ -84,10 +90,10 @@ def generate_xml_file():
|
|||
syntax = ET.SubElement(parameter, "syntax")
|
||||
ET.SubElement(syntax, ARRAY_TYPES.get(obj[2], None))
|
||||
DM_PARAM_COUNT += 1
|
||||
|
||||
tree = ET.ElementTree(root)
|
||||
|
||||
tree.write(XML_FILE, encoding ='UTF-8', xml_declaration = True)
|
||||
|
||||
xml_file = open(XML_FILE, "w")
|
||||
xml_file.write(pretty_format(root))
|
||||
xml_file.close()
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hr:v:p:", ["remote-dm=", "vendor-list=", "vendor-prefix="])
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue