(infile, sourcepath, outfile)
| 21 | |
| 22 | #---------------------------------------------------------------------- |
| 23 | def 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 | |
| 46 | def main(argv): |
| 47 | inputfile = '' |
no test coverage detected