2024-10-14 15:05:23 +01:00
|
|
|
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"))
|
|
|
|
|
2024-10-14 15:05:23 +01:00
|
|
|
# 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"))
|
2024-10-14 15:05:23 +01:00
|
|
|
|
|
|
|
# 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"))
|
2024-10-14 15:05:23 +01:00
|
|
|
except Exception as e:
|
2024-10-19 13:03:04 +01:00
|
|
|
print(colored(f" Error occurred when transferring files: {str(e)}", "red"))
|