Last active
August 29, 2015 14:13
-
-
Save whitmo/a8c069173e0af4a1235f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def copy_into(directory, target_dir): | |
with directory.relpath(): | |
for pth in path('./').walk(): | |
tgt = target_dir.joinpath(*pth.splitpath()) | |
if pth.isdir(): | |
tgt.mkdir_p() | |
continue | |
if pth.islink(): | |
link = pth.realpath().relpath() | |
new_tgt = target_dir.joinpath(*link.splitpath()) | |
if not new_tgt.exists(): | |
link.copyfile(new_tgt) | |
with tgt.parent: | |
new_tgt.symlink(tgt) | |
continue | |
else: | |
pth.copyfile(tgt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment