diff options
| author | mat <github@matdoes.dev> | 2022-05-28 20:59:22 -0500 |
|---|---|---|
| committer | mat <github@matdoes.dev> | 2022-05-28 20:59:22 -0500 |
| commit | 9c1c2862361a4863cfd0af36c80705fb6213c3a4 (patch) | |
| tree | aafbc0089624da25c530abdfa8e8435cb12f9347 /codegen/lib/utils.py | |
| parent | 8cd0ff2aac9f8a03446f897c48fc92b00b5291a2 (diff) | |
| download | azalea-drasl-9c1c2862361a4863cfd0af36c80705fb6213c3a4.tar.xz | |
default block properties
Diffstat (limited to 'codegen/lib/utils.py')
| -rw-r--r-- | codegen/lib/utils.py | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/codegen/lib/utils.py b/codegen/lib/utils.py index 77a7b2d4..fb43af21 100644 --- a/codegen/lib/utils.py +++ b/codegen/lib/utils.py @@ -11,7 +11,12 @@ def to_snake_case(name: str): def to_camel_case(name: str): s = re.sub('_([a-z])', lambda m: m.group(1).upper(), name) - return s[0].upper() + s[1:] + s = s[0].upper() + s[1:] + # if the first character is a number, we need to add an underscore + # maybe we could convert it to the number name (like 2 would become "two")? + if s[0].isdigit(): + s = f'_{s}' + return s def padded_hex(n: int): |
