Source code for xsdata.formats.dataclass.utils
stop_words = [
"and",
"except",
"lambda",
"with",
"as",
"finally",
"nonlocal",
"while",
"assert",
"false",
"none",
"yield",
"break",
"for",
"not",
"class",
"from",
"or",
"continue",
"global",
"pass",
"def",
"if",
"raise",
"del",
"import",
"return",
"elif",
"in",
"true",
"else",
"is",
"try",
]
[docs]def safe_snake(string: str) -> str:
if not string:
return "empty"
if string.lower() in stop_words:
return f"{string}_value"
if string[0].isdigit():
return f"value_{string}"
return string