neuron-zk-generator/src/lib/transfer_files.py

31 lines
1.1 KiB
Python
Raw Normal View History

import shutil
from termcolor import colored
def transfer_files(target_dir, source_dir):
try:
2024-10-19 13:03:04 +01:00
# Copy templates
print(colored("  Copying HTML/MD templates...", "blue"))
shutil.copytree(
f"{source_dir}/.neuron-generator/templates", target_dir, dirs_exist_ok=True
)
neuron_template = open(f"{target_dir}/neuron.dhall", "x")
neuron_template.close()
print(colored("  Templates transferred!", "green"))
# Copy images to /static
2024-10-19 13:03:04 +01:00
print(colored("  Copying static files...", "blue"))
shutil.copytree(
f"{source_dir}/img",
f"{target_dir}/static",
)
print(colored("  Static files transferred!", "green"))
print(colored("  Copying zettels...", "blue"))
# Copy notes
shutil.copytree(f"{source_dir}/zk", f"{target_dir}", dirs_exist_ok=True)
2024-10-19 13:03:04 +01:00
print(colored("  Zettels transferred!", "green"))
except Exception as e:
2024-10-19 13:03:04 +01:00
print(colored(f"  Error occurred when transferring files: {str(e)}", "red"))