Skip to content
This repository was archived by the owner on Mar 6, 2026. It is now read-only.

Commit f113bde

Browse files
committed
Adds Path class and changes path to package
1 parent 889870b commit f113bde

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

scripts/microgenerator/generate.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
import os
2727
import glob
2828
import logging
29-
import re
3029
from collections import defaultdict
31-
from typing import List, Dict, Any, Iterator
30+
from pathlib import Path
31+
from typing import List, Dict, Any
3232

3333
from . import name_utils
3434
from . import utils
@@ -497,22 +497,23 @@ def analyze_source_files(
497497
# Section 3: Code Generation
498498
# =============================================================================
499499

500+
500501
def _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

518519
def 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

Comments
 (0)