itchcraft.prefs
User preferences
Attributes
Helper union type consisting of an |
Classes
Whether or not a person’s skin is particularly sensitive. |
|
The age cohort of a person. |
|
The duration of a demo session. |
|
User preferences for a bite healer demo session. |
Functions
|
Returns the default preference for a given |
|
Parses a given value into an |
Module Contents
- itchcraft.prefs.CliEnum
Helper union type consisting of an
Enumand its stringified values.If a command line switch is backed by an Enum, then allow the enum to stand in for that switch.
For example, if you have the following Enum class:
from enum import Enum class Widget(Enum): FOO = 1 BAR = 2
and an associated command line switch
--widget, which can take the form of either--widget fooand--widget bar, then CliEnum[Widget] means that the four valuesWidget.FOO,Widget.BAR,"foo", and"bar"should be accepted.Widget.FOO is equivalent to
"foo", while Widget.BAR stands in for"bar":from itchcraft.prefs import CliEnum, parse def frob(widget: CliEnum[Widget]) -> None: real_widget: Widget = parse(widget, Widget) ... frob("foo") frob("bar") frob(Widget.FOO) # same as frob("foo") frob(Widget.BAR) # same as frob("bar")
- class itchcraft.prefs.SkinSensitivity
Bases:
enum.EnumWhether or not a person’s skin is particularly sensitive.
- SENSITIVE = 1
- REGULAR = 2
- class itchcraft.prefs.Generation
Bases:
enum.EnumThe age cohort of a person.
- CHILD = 1
- ADULT = 2
- class itchcraft.prefs.Duration
Bases:
enum.EnumThe duration of a demo session.
- SHORT = 1
- MEDIUM = 2
- LONG = 3
- class itchcraft.prefs.Preferences
User preferences for a bite healer demo session.
- skin_sensitivity: SkinSensitivity
- generation: Generation
- itchcraft.prefs.default(enum_type)
Returns the default preference for a given
Enumtype.- Parameters:
enum_type (type[_E]) – Enum type which exists as an attribute in
Preferencesand whose corresponding attribute name is equal to the type name converted to snake case.- Return type:
str
- itchcraft.prefs.parse(value, enum_type)
Parses a given value into an
Enumif it isn’t one yet.- Parameters:
value (CliEnum[_E]) – an Enum value or a corresponding name, written in lower case.
enum_type (type[_E]) – the type of the Enum to parse into.
- Returns:
an instance of enum_type that represents value. If value is already an instance of enum_type, then the return value is value itself.
- Return type:
_E