1- from pathlib import Path
21from os import getcwd
2+ from pathlib import Path
33from threading import Lock
44
55from je_auto_control .utils .json .json_file import write_action_json
@@ -20,43 +20,47 @@ def create_dir(dir_name: str) -> None:
2020 )
2121
2222
23- def create_template (parent_name : str ) -> None :
24- keyword_dir_path = Path (getcwd () + "/" + parent_name + "/keyword" )
25- executor_dir_path = Path (getcwd () + "/" + parent_name + "/executor" )
23+ def create_template (parent_name : str , project_path : str = None ) -> None :
24+ if project_path is None :
25+ project_path = getcwd ()
26+ keyword_dir_path = Path (project_path + "/" + parent_name + "/keyword" )
27+ executor_dir_path = Path (project_path + "/" + parent_name + "/executor" )
2628 lock = Lock ()
2729 if keyword_dir_path .exists () and keyword_dir_path .is_dir ():
28- write_action_json (getcwd () + "/" + parent_name + "/keyword/keyword1.json" , template_keyword_1 )
29- write_action_json (getcwd () + "/" + parent_name + "/keyword/keyword2.json" , template_keyword_2 )
30- write_action_json (getcwd () + "/" + parent_name + "/keyword/bad_keyword_1.json" , bad_template_1 )
30+ write_action_json (project_path + "/" + parent_name + "/keyword/keyword1.json" , template_keyword_1 )
31+ write_action_json (project_path + "/" + parent_name + "/keyword/keyword2.json" , template_keyword_2 )
32+ write_action_json (project_path + "/" + parent_name + "/keyword/bad_keyword_1.json" , bad_template_1 )
3133 if executor_dir_path .exists () and keyword_dir_path .is_dir ():
3234 lock .acquire ()
3335 try :
34- with open (getcwd () + "/" + parent_name + "/executor/executor_one_file.py" , "w+" ) as file :
36+ with open (project_path + "/" + parent_name + "/executor/executor_one_file.py" , "w+" ) as file :
3537 file .write (
3638 executor_template_1 .replace (
3739 "{temp}" ,
38- getcwd () + "/" + parent_name + "/keyword/keyword1.json"
40+ project_path + "/" + parent_name + "/keyword/keyword1.json"
3941 )
4042 )
41- with open (getcwd () + "/" + parent_name + "/executor/executor_bad_file.py" , "w+" ) as file :
43+ with open (project_path + "/" + parent_name + "/executor/executor_bad_file.py" , "w+" ) as file :
4244 file .write (
4345 bad_executor_template_1 .replace (
4446 "{temp}" ,
45- getcwd () + "/" + parent_name + "/keyword/bad_keyword_1.json"
47+ project_path + "/" + parent_name + "/keyword/bad_keyword_1.json"
4648 )
4749 )
48- with open (getcwd () + "/" + parent_name + "/executor/executor_folder.py" , "w+" ) as file :
50+ with open (project_path + "/" + parent_name + "/executor/executor_folder.py" , "w+" ) as file :
4951 file .write (
5052 executor_template_2 .replace (
5153 "{temp}" ,
52- getcwd () + "/" + parent_name + "/keyword"
54+ project_path + "/" + parent_name + "/keyword"
5355 )
5456 )
5557 finally :
5658 lock .release ()
5759
5860
59- def create_project_dir (parent_name : str ) -> None :
60- create_dir (getcwd () + "/" + parent_name + "/keyword" )
61- create_dir (getcwd () + "/" + parent_name + "/executor" )
61+ def create_project_dir (parent_name : str , project_path : str = None ) -> None :
62+ if project_path is None :
63+ project_path = getcwd ()
64+ create_dir (project_path + "/" + parent_name + "/keyword" )
65+ create_dir (project_path + "/" + parent_name + "/executor" )
6266 create_template (parent_name )
0 commit comments