2626import os
2727import glob
2828import logging
29- import re
3029from collections import defaultdict
31- from typing import List , Dict , Any , Iterator
30+ from pathlib import Path
31+ from typing import List , Dict , Any
3232
3333from . import name_utils
3434from . import utils
@@ -497,22 +497,23 @@ def analyze_source_files(
497497# Section 3: Code Generation
498498# =============================================================================
499499
500+
500501def _generate_import_statement (
501- context : List [Dict [str , Any ]], key : str , path : str
502+ context : List [Dict [str , Any ]], key : str , package : str
502503) -> str :
503504 """Generates a formatted import statement from a list of context dictionaries.
504505
505506 Args:
506507 context: A list of dictionaries containing the data.
507508 key: The key to extract from each dictionary in the context.
508- path : The base import path (e.g., "google.cloud.bigquery_v2.services").
509+ package : The base import package (e.g., "google.cloud.bigquery_v2.services").
509510
510511 Returns:
511512 A formatted, multi-line import statement string.
512513 """
513514 names = sorted (list (set ([item [key ] for item in context ])))
514515 names_str = ",\n " .join (names )
515- return f"from { path } import (\n { names_str } \n )"
516+ return f"from { package } import (\n { names_str } \n )"
516517
517518
518519def generate_code (config : Dict [str , Any ], analysis_results : tuple ) -> None :
@@ -525,8 +526,8 @@ def generate_code(config: Dict[str, Any], analysis_results: tuple) -> None:
525526
526527 templates_config = config .get ("templates" , [])
527528 for item in templates_config :
528- template_path = os . path . join ( config_dir , item ["template" ])
529- output_path = os . path . join ( project_root , item ["output" ])
529+ template_path = str ( Path ( config_dir ) / item ["template" ])
530+ output_path = str ( Path ( project_root ) / item ["output" ])
530531
531532 template = utils .load_template (template_path )
532533 methods_context = []
0 commit comments