import argparse import sys import re import os from pathlib import Path import shutil def make_safe(path): # make sure the path does not climb up path = Path(path) while len(path.parts) > 0 and path.parts[0] == "..": path = Path(*path.parts[1:]) return path def contains_envvars(path): for part in path.parts: if str(part)[0] == "$": return True return False def find_file_refs(content, location): temp = "" last = 0 files = {} fileregex = re.compile(r"(? {}".format(file, files[file])) exit(0) # copy all files found in netlist earlier for file in files: src = Path(file) dst = Path(files[file]) if not src.exists(): print("src does not exist: {}".format(str(src))) continue # create directory dst.parent.mkdir(parents=True) shutil.copyfile(str(src), str(dst)) if __name__ == "__main__": main()