2024-11-17 15:34:44 +00:00
|
|
|
import glob
|
2024-10-14 15:05:23 +01:00
|
|
|
import shutil
|
2024-11-11 15:49:01 +00:00
|
|
|
|
2024-10-14 15:05:23 +01:00
|
|
|
from termcolor import colored
|
|
|
|
|
|
|
|
|
|
|
|
def transfer_files(target_dir, source_dir):
|
|
|
|
try:
|
2024-10-19 13:03:04 +01:00
|
|
|
# Copy templates
|
2024-11-11 15:49:01 +00:00
|
|
|
print(colored("INFO Copying HTML/MD templates...", "light_blue"))
|
2024-10-19 13:03:04 +01:00
|
|
|
shutil.copytree(
|
|
|
|
f"{source_dir}/.neuron-generator/templates", target_dir, dirs_exist_ok=True
|
|
|
|
)
|
|
|
|
|
2024-12-09 18:16:08 +00:00
|
|
|
shutil.copy2(
|
|
|
|
f"{source_dir}/.neuron-generator/neuron.dhall",
|
|
|
|
f"{target_dir}",
|
2024-11-17 15:34:44 +00:00
|
|
|
)
|
|
|
|
|
2024-12-09 18:16:08 +00:00
|
|
|
print(colored("SUCCESS Templates transferred", "light_green"))
|
|
|
|
|
2024-10-14 15:05:23 +01:00
|
|
|
# Copy images to /static
|
2024-11-11 15:49:01 +00:00
|
|
|
print(colored("INFO Copying static files...", "light_blue"))
|
2024-11-17 15:34:44 +00:00
|
|
|
shutil.copytree(f"{source_dir}/img", f"{target_dir}/static", dirs_exist_ok=True)
|
2025-01-14 17:01:25 +00:00
|
|
|
|
|
|
|
# Copy favicon
|
2024-12-09 18:16:08 +00:00
|
|
|
shutil.copy2(
|
|
|
|
f"{source_dir}/.neuron-generator/templates/favicon/favicon.ico",
|
|
|
|
f"{target_dir}/static",
|
|
|
|
)
|
2024-10-19 13:03:04 +01:00
|
|
|
|
2024-12-09 18:16:08 +00:00
|
|
|
print(colored("SUCCESS Static files transferred", "light_green"))
|
2024-11-17 15:34:44 +00:00
|
|
|
|
2024-11-11 15:49:01 +00:00
|
|
|
print(colored("INFO Copying zettels...", "light_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-11-11 15:49:01 +00:00
|
|
|
print(colored("SUCCESS Zettels transferred", "light_green"))
|
2024-10-14 15:05:23 +01:00
|
|
|
except Exception as e:
|
2024-11-11 15:49:01 +00:00
|
|
|
print(
|
|
|
|
colored(
|
|
|
|
f"ERROR Error occurred when transferring files: {str(e)}", "light_red"
|
|
|
|
)
|
|
|
|
)
|