Skip to content
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
b9d4a04
chore: removes old proof of concept
chalmerlowe Sep 11, 2025
5b4d538
removes old __init__.py
chalmerlowe Sep 11, 2025
132c571
Adds two utility files to handle basic tasks
chalmerlowe Sep 11, 2025
90b224e
Adds a configuration file for the microgenerator
chalmerlowe Sep 11, 2025
e071eab
Removes unused comment
chalmerlowe Sep 11, 2025
dc72a98
chore: adds noxfile.py for the microgenerator
chalmerlowe Sep 11, 2025
7318f0b
feat: microgen - adds two init file templates
chalmerlowe Sep 12, 2025
07910c5
feat: adds _helpers.py.js template
chalmerlowe Sep 12, 2025
dc54c99
Updates with two usage examples
chalmerlowe Sep 12, 2025
28de5f8
feat: adds two partial templates for creating method signatures
chalmerlowe Sep 12, 2025
c457754
feat: Add microgenerator __init__.py
chalmerlowe Sep 15, 2025
595e59f
feat: Add AST analysis utilities
chalmerlowe Sep 15, 2025
44a0777
feat: Add source file analysis capabilities
chalmerlowe Sep 15, 2025
3e9ade6
feat: adds code generation logic
chalmerlowe Sep 15, 2025
485b9d4
removes extraneous content
chalmerlowe Sep 15, 2025
a4276fe
feat: microgen - adds code generation logic
chalmerlowe Sep 15, 2025
1d0d036
feat: microgen - adds main execution and post-processing logic
chalmerlowe Sep 15, 2025
eff7223
minor tweak to markers
chalmerlowe Sep 15, 2025
0734bf8
feat: Add testing directory\n\nAdds the scripts/microgenerator/testin…
chalmerlowe Sep 16, 2025
510a87b
feat: Enhance to_snake_case to handle acronyms\n\nImproves the to_sna…
chalmerlowe Sep 16, 2025
771eceb
Merge branch 'autogen' into feat/upgrade-name-utils
chalmerlowe Sep 23, 2025
4336599
Update scripts/microgenerator/generate.py
chalmerlowe Sep 23, 2025
3e02f96
Update scripts/microgenerator/testing/constraints-3.13.txt
chalmerlowe Sep 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions scripts/microgenerator/name_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@


def to_snake_case(name: str) -> str:
"""Converts a PascalCase name to snake_case."""
return re.sub(r"(?<!^)(?=[A-Z])", "_", name).lower()
"""Converts a PascalCase name to snake_case, handling acronyms."""
if not name:
return ""
# Add underscore between lower and upper case
name = re.sub(r"([a-z0-9])([A-Z])", r"\1_\2", name)
# Add underscore between multiple upper case and a following lower case
name = re.sub(r"([A-Z])([A-Z][a-z])", r"\1_\2", name)
return name.lower()


def generate_service_names(class_name: str) -> Dict[str, str]:
Expand Down Expand Up @@ -60,12 +66,18 @@ def method_to_request_class_name(method_name: str) -> str:
Returns:
The inferred PascalCase name for the corresponding request class.

Raises:
ValueError: If method_name is empty.

Example:
>>> method_to_request_class_name('get_dataset')
'GetDatasetRequest'
>>> method_to_request_class_name('list_jobs')
'ListJobsRequest'
"""
if not method_name:
raise ValueError("method_name cannot be empty")

# e.g., "get_dataset" -> ["get", "dataset"]
parts = method_name.split("_")
# e.g., ["get", "dataset"] -> "GetDataset"
Expand Down
Loading