Last active
June 21, 2017 14:32
-
-
Save grigorisg9gr/0b686e1345597a4cd53470e065c7e64c to your computer and use it in GitHub Desktop.
Copy_file(s)_to_dir_from_python
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 save_file(pout): | |
""" | |
Copy some of the execution files. | |
Those are hardcoded and include the file that the function is. | |
:return: | |
""" | |
from os import getcwd, makedirs | |
from os.path import join | |
from shutil import copy2 | |
try: | |
# get the python file name | |
pfn = __file__ | |
except NameError: | |
m1 = 'Probably a notebook, cannot save it.' | |
print(m1) | |
return -1 | |
p1 = getcwd() | |
files = [pfn, 'other_file_in_path.py'] | |
for f in files: | |
makedirs(pout) | |
po = join(pout, f) | |
copy2(join(p1, f), po) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment