in aws_codeseeder/_bundle.py [0:0]
def generate_dir(out_dir: str, dir: str, name: str) -> str:
absolute_dir = os.path.realpath(dir)
final_dir = os.path.realpath(os.path.join(out_dir, name))
LOGGER.debug("absolute_dir: %s", absolute_dir)
LOGGER.debug("final_dir: %s", final_dir)
os.makedirs(final_dir, exist_ok=True)
shutil.rmtree(final_dir)
LOGGER.debug("Copying files to %s", final_dir)
files: List[str] = _list_files(path=absolute_dir)
if len(files) == 0:
raise ValueError(f"{name} ({absolute_dir}) is empty!")
for file in files:
LOGGER.debug(f"***file={file}")
relpath = os.path.relpath(file, absolute_dir)
new_file = os.path.join(final_dir, relpath)
LOGGER.debug("Copying file to %s", new_file)
os.makedirs(os.path.dirname(new_file), exist_ok=True)
LOGGER.debug("Copying file to %s", new_file)
shutil.copy(src=file, dst=new_file)
return final_dir