MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / modifyXML

Function modifyXML

fixcoveragefilepaths.py:23–44  ·  view source on GitHub ↗
(infile, sourcepath, outfile)

Source from the content-addressed store, hash-verified

21
22#----------------------------------------------------------------------
23def modifyXML(infile, sourcepath, outfile):
24 tree = xml.ElementTree(file=infile)
25 root = tree.getroot()
26
27 source_dir = root.find('sources/source')
28 actual_src_drive, actual_src_tail = os.path.splitdrive(sourcepath)
29 src_drive, src_tail = os.path.splitdrive(source_dir.text)
30 if actual_src_drive.lower() == src_drive.lower():
31 # Replace the filename with the case sensitive path
32 # The result filename is relative to the provided source path
33 for class_elem in root.iter("class"):
34 filepath = "%s\%s" % (source_dir.text,class_elem.attrib['filename'])
35 case_sensitive_filepath = casedpath_unc(filepath)
36 rel_filepath = remove_prefix(case_sensitive_filepath, src_drive+actual_src_tail+"\\")
37 class_elem.attrib['filename'] = rel_filepath
38 class_elem.attrib['name'] = os.path.basename(rel_filepath)
39 source_dir.text = sourcepath
40 tree = xml.ElementTree(root)
41 tree.write(outfile, encoding="utf-8",xml_declaration=True)
42 else:
43 print("Error: Source drive in input file does not match the provided source path's drive")
44 sys.exit(-1)
45
46def main(argv):
47 inputfile = ''

Callers 1

mainFunction · 0.85

Calls 4

casedpath_uncFunction · 0.85
remove_prefixFunction · 0.85
iterMethod · 0.80
findMethod · 0.45

Tested by

no test coverage detected