The Enumeration Base Class
The base class of Smarter’s enumerations.
- class smarter_types.enum.SmarterEnumAbstract(new_class_name, /, names, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
EnumThe base class of Smarter’s enumerations, whose values are strings.
It adds class methods that list the values, and the url slugs made from them.
str()of a member is its value.from smarter_types import SAMKinds SAMKinds.all() # ["Plugin", "ApiPlugin", ...] str(SAMKinds.SECRET) # "Secret"
- classmethod list_all() str[source]
Return every member’s value, as one comma-separated string, e.g. for an error message.
- Returns:
The values, separated by
", ".- Return type:
- classmethod all_slugs() list[str][source]
Return the url slugs of every value, singular and plural.
- Returns:
singular_slugs(), thenplural_slugs().- Return type:
- classmethod singular_slugs() list[str][source]
Return the singular url slug of every value: the value, in lower case.
- classmethod plural_slugs() list[str][source]
Return the plural url slug of every value: the value, in lower case, with an
s.
- classmethod from_url(url: str | bytes) str | None[source]
Return the first slug of a Smarter api url that is one of this enumeration’s slugs.
SAMKinds.from_url("http://localhost:9357/api/v1/cli/example_manifest/Account/") # "account" SAMKinds.from_url("http://localhost:9357/api/v1/cli/whoami/") # None