Other¶
Miscellaneous utilities.
from prairielearn import ...
escape_unicode_string ¶
Replace invisible/unprintable characters with a text representation of their hex id: <U+xxxx>
A character is considered invisible if its category is "control" or "format", as reported by the 'unicodedata' library.
More info on unicode categories: https://en.wikipedia.org/wiki/Unicode_character_property#General_Category
Returns:
Type | Description |
---|---|
str
|
A string with invisible characters replaced |
full_unidecode ¶
Do unidecode of input and replace the unicode minus with the normal one.
Returns:
Type | Description |
---|---|
str
|
A fully decoded string without unicode characters. |
get_unit_registry ¶
get_unit_registry() -> UnitRegistry
Get a unit registry using cache folder valid on production machines.
https://pint.readthedocs.io/en/stable/index.html
Returns:
Type | Description |
---|---|
UnitRegistry
|
A process-specific unit registry. |
get_uuid ¶
get_uuid() -> str
Return the string representation of a new random UUID. First character of this uuid is guaranteed to be an alpha (at the expense of a slight loss in randomness).
This is done because certain web components need identifiers to start with letters and not numbers.
Returns:
Type | Description |
---|---|
str
|
A UUID starting with an alpha char |
index2key ¶
Use when generating ordered lists of the form ['a', 'b', ..., 'z', 'aa', 'ab', ..., 'zz', 'aaa', 'aab', ...]
Returns:
Type | Description |
---|---|
str
|
Alphabetic key in the form |
iter_keys ¶
A continuous alphabetic list of the form ['a', 'b', ..., 'z', 'aa', 'ab', ..., 'zz', 'aaa', 'aab', ...]
.
Returns:
Type | Description |
---|---|
None
|
A generator that yields strings in the specified format. |