openrig.naming.normalizers module
Normalization functions for token values.
Each public function in this module conforms to the Normalizer signature:
Callable[[object], str]
This means they accept any object (the raw token value before normalization,
which may be a str, an Enum, or any other type) and always return a
plain str. Empty string signals “no value provided”.
All functions are registered in NORMALIZER_MAP at the bottom of the module,
which is the single source of truth consumed by rules.build_normalizers().
- Note on the
if not valueguard: These functions use
if not value: return ""as a fast-exit for falsy inputs. This is intentional: theManagernever passesNoneto a normalizer (it returns""before calling them), and a falsy non-None value such as0orFalseis not a valid token value in this system. If that assumption changes, the guard should be replaced with an explicitif value is None: return "".
- openrig.naming.normalizers.side(value: object) str[source]
Normalizes a side value to its standard abbreviation.
Maps long-form or mixed-case side strings to their canonical short form (e.g.
'Left'→'l'). Values not found in the mapping are converted to camelCase as a fallback.- Parameters:
value – The raw side value to normalize.
- Returns:
The normalized side string (e.g.
'left'→'l'), or""if the value is falsy.
- openrig.naming.normalizers.descriptor(value: object) str[source]
Normalizes a descriptor to camelCase.
Converts any casing or separator style to camelCase to avoid conflicts with the naming separator (e.g.
'upper_arm'→'upperArm').- Parameters:
value – The raw descriptor value to normalize.
- Returns:
The camelCase descriptor string, or
""if the value is falsy.
- openrig.naming.normalizers.normalize_type(value: object) str[source]
Normalizes a type token to camelCase.
Registered in
NORMALIZER_MAPunder the key"type". The function is namednormalize_typeto avoid shadowing thetypebuiltin.- Parameters:
value – The raw type value to normalize.
- Returns:
The camelCase type string, or
""if the value is falsy.
- openrig.naming.normalizers.pascal_case(value: object) str[source]
Normalizes a token value to PascalCase.
- Parameters:
value – The raw value to normalize.
- Returns:
The PascalCase string, or
""if the value is falsy.
- openrig.naming.normalizers.snake_case(value: object) str[source]
Normalizes a token value to snake_case.
- Parameters:
value – The raw value to normalize.
- Returns:
The snake_case string, or
""if the value is falsy.
- openrig.naming.normalizers.kebab_case(value: object) str[source]
Normalizes a token value to kebab-case.
- Parameters:
value – The raw value to normalize.
- Returns:
The kebab-case string, or
""if the value is falsy.
- openrig.naming.normalizers.clean(value: object) str[source]
Cleans a token value by replacing invalid characters.
- Parameters:
value – The raw value to normalize.
- Returns:
The cleaned string, or
""if the value is falsy.
- openrig.naming.normalizers.version(value: object) str[source]
Normalizes a version number to the
vNNNformat.Accepts both raw integers (
1→'v001') and already-formatted strings ('v3'→'v003').- Parameters:
value – The raw version value to normalize (
intorstr).- Returns:
The normalized version string (e.g.
'v001'), or""if falsy.
- openrig.naming.normalizers.upper(value: object) str[source]
Normalizes a token value to uppercase.
- Parameters:
value – The raw value to normalize.
- Returns:
The uppercase string, or
""if the value is falsy.
- openrig.naming.normalizers.lower(value: object) str[source]
Normalizes a token value to lowercase.
- Parameters:
value – The raw value to normalize.
- Returns:
The lowercase string, or
""if the value is falsy.
- openrig.naming.normalizers.capitalize(value: object) str[source]
Normalizes a token value by capitalizing its first letter.
- Parameters:
value – The raw value to normalize.
- Returns:
The capitalized string, or
""if the value is falsy.
- openrig.naming.normalizers.strip_digits(value: object) str[source]
Removes all digit characters from a token value.
- Parameters:
value – The raw value to normalize.
- Returns:
The string with all digits removed, or
""if the value is falsy.
- openrig.naming.normalizers.strip_namespace(value: object) str[source]
Removes the namespace prefix from a token value.
Strips everything up to and including the last
:separator.- Parameters:
value – The raw value to normalize (e.g.
'ns:nodeName').- Returns:
The string without its namespace prefix, or
""if the value is falsy.