summaryrefslogtreecommitdiffstats
path: root/rtemsspec/content.py
diff options
context:
space:
mode:
Diffstat (limited to 'rtemsspec/content.py')
-rw-r--r--rtemsspec/content.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/rtemsspec/content.py b/rtemsspec/content.py
index 74b2b43e..3c28ab66 100644
--- a/rtemsspec/content.py
+++ b/rtemsspec/content.py
@@ -1031,3 +1031,14 @@ def enabled_by_to_exp(enabled_by: Any, mapper: ExpressionMapper) -> str:
if exp.startswith("("):
return exp[1:-1]
return exp
+
+
+_CAMEL_CASE_TO_UPPER = re.compile(r"\s+(.)")
+_CAMEL_CASE_DISCARD = re.compile(r"[^ \t\n\r\f\va-zA-Z0-9]")
+
+
+def to_camel_case(name: str) -> str:
+ """ Returns the name in CamelCase. """
+ return name[0].upper() + _CAMEL_CASE_TO_UPPER.sub(
+ lambda match: match.group(1).upper(),
+ _CAMEL_CASE_DISCARD.sub(" ", name[1:].replace("+", "X")))