summaryrefslogtreecommitdiffstats
path: root/src/aristaproto/compile/naming.py
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-29 09:40:12 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-07-29 09:40:12 +0000
commit14b40ec77a4bf8605789cc3aff0eb87625510a41 (patch)
tree4064d27144d6deaabfcd96df01bd996baa8b51a0 /src/aristaproto/compile/naming.py
parentInitial commit. (diff)
downloadpython-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.py21
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)