Esempio n. 1
0
 def _combine_tracks(self, first: ElementTree, second: ElementTree):
     """
     Append trk of first root to the second root
     """
     first.append(second.find(TRK_ELEMENT))
     self.roots[0] = first
Esempio n. 2
0
        strip_xml(sub)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=
        'scan the project working directory and build a matching file tree representation in the iar project configuration'
    )
    parser.add_argument('file',
                        type=str,
                        help='a .ewp file of the project to load')

    args = parser.parse_args()

    ewp_file = Path(args.file)
    if not ewp_file.exists() or ewp_file.suffix != '.ewp':
        error(f"could not find {ewp_file}")

    ewp_root = ElementTree(file=ewp_file).getroot()

    remove_all_files_and_folders(ewp_root)

    strip_xml(ewp_root)

    root_path = ewp_file.parent
    for child in build_working_tree(
            root_path, lambda path: get_path_from_workspace(root_path, path)):
        ewp_root.append(child)

    ewp_file.write_text(prettify(ewp_root))