diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-29 09:40:12 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-07-29 09:40:12 +0000 |
commit | 14b40ec77a4bf8605789cc3aff0eb87625510a41 (patch) | |
tree | 4064d27144d6deaabfcd96df01bd996baa8b51a0 /src/aristaproto/compile/naming.py | |
parent | Initial commit. (diff) | |
download | python-aristaproto-upstream.tar.xz python-aristaproto-upstream.zip |
Adding upstream version 1.2+20240521.upstream/1.2+20240521upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/aristaproto/compile/naming.py')
-rw-r--r-- | src/aristaproto/compile/naming.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/aristaproto/compile/naming.py b/src/aristaproto/compile/naming.py new file mode 100644 index 0000000..0c45dde --- /dev/null +++ b/src/aristaproto/compile/naming.py @@ -0,0 +1,21 @@ +from aristaproto import casing + + +def pythonize_class_name(name: str) -> str: + return casing.pascal_case(name) + + +def pythonize_field_name(name: str) -> str: + return casing.safe_snake_case(name) + + +def pythonize_method_name(name: str) -> str: + return casing.safe_snake_case(name) + + +def pythonize_enum_member_name(name: str, enum_name: str) -> str: + enum_name = casing.snake_case(enum_name).upper() + find = name.find(enum_name) + if find != -1: + name = name[find + len(enum_name) :].strip("_") + return casing.sanitize_name(name) |