trestle.common.str_utils
trestle.common.str_utils
¤
Trestle String Utils.
Classes¤
AliasMode
¤
Bases: Enum
Allowed formats for classname alias.
Currently there are only two. If others are added, check they get handled properly in the code.
Source code in trestle/common/str_utils.py
23 24 25 26 27 28 29 30 31 |
|
Functions¤
alias_to_classname(alias, mode)
¤
Return class name based dashed or snake alias.
This is applicable creating dynamic wrapper model for a list or dict field.
Source code in trestle/common/str_utils.py
95 96 97 98 99 100 101 102 103 |
|
as_bool(string_or_none)
¤
Convert string to boolean.
Source code in trestle/common/str_utils.py
127 128 129 130 131 132 133 134 135 136 |
|
as_string(string_or_none)
¤
Convert string or None to itself or empty string.
Source code in trestle/common/str_utils.py
122 123 124 |
|
classname_to_alias(classname, mode)
¤
Return oscal key name or field element name based on class name.
This is applicable when asking for a singular element.
Source code in trestle/common/str_utils.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
|
dash_to_underscore(name)
¤
Convert dash to underscore.
Source code in trestle/common/str_utils.py
111 112 113 |
|
spaces_and_caps_to_lower_single_spaces(spaced_str)
¤
Convert caps and duplicate spaces to lower with single spaces.
Source code in trestle/common/str_utils.py
71 72 73 74 |
|
spaces_and_caps_to_snake(spaced_str)
¤
Convert caps and spaces to snake.
Source code in trestle/common/str_utils.py
65 66 67 68 |
|
string_from_root(item_with_root)
¤
Convert root to string if present.
Source code in trestle/common/str_utils.py
139 140 141 |
|
strip_lower_equals(str_a, str_b)
¤
Safe test of lower string equality allowing Nones.
If either argument is None the result is False because the intent is to report if they are equal as actual strings.
Source code in trestle/common/str_utils.py
144 145 146 147 148 149 150 151 152 |
|
to_ncname(name)
¤
Convert to NCName.
Source code in trestle/common/str_utils.py
155 156 157 158 159 160 |
|
underscore_to_dash(name)
¤
Convert underscore to dash and drop final dash if present.
Source code in trestle/common/str_utils.py
116 117 118 119 |
|
handler: python