@@ -491,7 +491,6 @@ def analyze_source_files(
491491 # Make the pattern absolute
492492 absolute_pattern = os .path .join (project_root , pattern )
493493 source_files .extend (glob .glob (absolute_pattern , recursive = True ))
494-
495494 # PASS 1: Build the request argument schema from the types files.
496495 request_arg_schema = _build_request_arg_schema (source_files , project_root )
497496
@@ -552,14 +551,14 @@ def generate_code(config: Dict[str, Any], analysis_results: tuple) -> None:
552551 Generates source code files using Jinja2 templates.
553552 """
554553 data , all_imports , all_types , request_arg_schema = analysis_results
555- project_root = config ["project_root" ]
556- config_dir = config ["config_dir" ]
557554
558555 templates_config = config .get ("templates" , [])
559556 for item in templates_config :
560- template_path = str ( Path ( config_dir ) / item ["template" ])
561- output_path = str ( Path ( project_root ) / item ["output" ])
557+ template_name = item ["template" ]
558+ output_name = item ["output" ]
562559
560+ template_path = str (Path (config ["config_dir" ]) / template_name )
561+ output_path = str (Path (config ["project_root" ]) / output_name )
563562 template = utils .load_template (template_path )
564563 methods_context = []
565564 for class_name , methods in data .items ():
@@ -655,18 +654,20 @@ def find_project_root(start_path: str, markers: list[str]) -> str | None:
655654 return None
656655 current_path = parent_path
657656
658- # Load configuration from the YAML file.
659- config = utils .load_config (config_path )
657+ # Get the absolute path of the config file
658+ abs_config_path = os .path .abspath (config_path )
659+ config = utils .load_config (abs_config_path )
660660
661- # Determine the project root.
662- script_dir = os .path .dirname (os .path .abspath (__file__ ))
663- project_root = find_project_root (script_dir , ["setup.py" , ".git" ])
661+ # Determine the project root
662+ # Start searching from the directory of this script file
663+ script_file_dir = os .path .dirname (os .path .abspath (__file__ ))
664+ project_root = find_project_root (script_file_dir , [".git" ])
664665 if not project_root :
665- project_root = os .getcwd () # Fallback to current directory
666+ # Fallback to the directory from which the script was invoked
667+ project_root = os .getcwd ()
666668
667- # Set paths in the config dictionary.
668669 config ["project_root" ] = project_root
669- config ["config_dir" ] = os .path .dirname (os . path . abspath ( config_path ) )
670+ config ["config_dir" ] = os .path .dirname (abs_config_path )
670671
671672 return config
672673
@@ -707,9 +708,13 @@ def _execute_post_processing(config: Dict[str, Any]):
707708 all_end_index = i
708709
709710 if all_start_index != - 1 and all_end_index != - 1 :
710- for i in range (all_start_index + 1 , all_end_index ):
711- member = lines [i ].strip ().replace ('"' , "" ).replace ("," , "" )
712- if member :
711+ all_content = "" .join (lines [all_start_index + 1 : all_end_index ])
712+ # Extract quoted strings
713+ import re
714+
715+ found_members = re .findall (r'"([^"]+)"' , all_content )
716+ for member in found_members :
717+ if member not in all_list :
713718 all_list .append (member )
714719
715720 # --- Add new items and sort ---
@@ -722,7 +727,9 @@ def _execute_post_processing(config: Dict[str, Any]):
722727 for new_member in job .get ("add_to_all" , []):
723728 if new_member not in all_list :
724729 all_list .append (new_member )
725- all_list .sort ()
730+ all_list = sorted (list (set (all_list ))) # Ensure unique and sorted
731+ # Format for the template
732+ all_list = [f' "{ item } ",\n ' for item in all_list ]
726733
727734 # --- Render the new file content ---
728735 template = utils .load_template (template_path )
0 commit comments