Remap: Refactor scripts #177

Merged
Nick Alberelli merged 17 commits from :feature/refactor-remap-script into main 2023-12-07 16:17:27 +01:00
Showing only changes of commit 11848efcae - Show all commits

View File

@ -67,33 +67,26 @@ def get_josn_file_dir() -> str:
return Path(json_dir).joinpath("dir_map.json").__str__()
def get_bbatch_script_dir() -> Path:
bbatch_dir = input("Please select directory to save bbatch script to: ")
if not Path(bbatch_dir).is_dir():
raise Exception('Provided path is not a directory')
return Path(bbatch_dir)
def save_bbatch_script():
directory = get_current_dir()
file = directory.joinpath('remap_blender_paths.py')
source_file = directory.joinpath('remap_blender_paths.py')
variables = get_variables()
new_file_dir = get_bbatch_script_dir()
new_file_dir = directory.joinpath('dist')
with open(file, 'r', encoding='utf-8') as file:
data = file.readlines()
with open(source_file, 'r', encoding='utf-8') as source_file:
data = source_file.readlines()
for line in data:
if line.startswith('json_file_path ='):
data[data.index(line)] = f'json_file_path = "{variables[JSON_FILE_KEY]}"'
mapped_dir_name = Path(variables[CRAWL_DIR_KEY]).name
new_file = new_file_dir.joinpath(f'remap_blender_paths_for_{mapped_dir_name}.py')
with open(new_file, 'w', encoding='utf-8') as file:
file.writelines(data)
with open(new_file, 'w', encoding='utf-8') as source_file:
source_file.writelines(data)
print(f"bbatch script has been saved to {new_file.__str__()}")
print("This is your bbatch command")
print(
f'python -m bbatch {variables[CRAWL_DIR_KEY]} --script {new_file.__str__()} --nosave --recursive'
f'python -m bbatch {variables[CRAWL_DIR_KEY]} --script {new_file.absolute().__str__()} --nosave --recursive'
)