String utils
camel_case(string)
Convert a string to Camel Case by splitting on underscores and capitalizing each word.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
string
|
str
|
The input string to be converted. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The converted Camel Case string. |
Source code in blue/utils/string_utils.py
9 10 11 12 13 14 15 16 17 18 19 20 | |
decode_websafe_no_padding(encoded_data)
Decodes a url-safe base64 string without padding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
encoded_data
|
str
|
input url-safe base64 string to be decoded |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input encoded_data is empty. |
Returns:
Source code in blue/utils/string_utils.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
encode_websafe_no_padding(data)
Encodes a string to a url-safe base64 string without padding.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
input string to be encoded |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input data is empty. |
Returns:
| Type | Description |
|---|---|
str
|
Url-safe base64 encoded string without padding. |
Source code in blue/utils/string_utils.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
remove_non_alphanumeric(input_string)
Remove non-alphanumeric characters from a string, also replaces spaces with underscores.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_string
|
str
|
input string to be cleaned |
required |
Returns:
| Type | Description |
|---|---|
str
|
Cleaned string with only alphanumeric characters and underscores. |
Source code in blue/utils/string_utils.py
48 49 50 51 52 53 54 55 56 57 58 59 60 | |
safe_substitute(ts, **mappings)
Recursively substitute variables in a template string using both string.Template and Jinja2.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ts
|
str
|
The template string containing placeholders. |
required |
**mappings
|
Key-value pairs for substitution. |
{}
|
Returns:
| Type | Description |
|---|---|
|
The string with all placeholders substituted. |
Source code in blue/utils/string_utils.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |