evennia.utils.optionclasses¶
-
class
evennia.utils.optionclasses.
BaseOption
(handler, key, description, default)[源代码]¶ 基类:
object
Abstract Class to deal with encapsulating individual Options. An Option has a name/key, a description to display in relevant commands and menus, and a default value. It saves to the owner’s Attributes using its Handler’s save category.
Designed to be extremely overloadable as some options can be cantankerous.
- Properties:
valid: Shortcut to the loaded VALID_HANDLER. validator_key (str): The key of the Validator this uses.
-
__init__
(handler, key, description, default)[源代码]¶ - 参数
handler (OptionHandler) – The OptionHandler that ‘owns’ this Option.
key (str) – The name this will be used for storage in a dictionary. Must be unique per OptionHandler.
description (str) – What this Option’s text will show in commands and menus.
default – A default value for this Option.
-
property
changed
¶
-
property
default
¶
-
property
value
¶
-
set
(value, **kwargs)[源代码]¶ Takes user input and stores appropriately. This method allows for passing extra instructions into the validator.
- 参数
value (str) – The new value of this Option.
kwargs (any) – Any kwargs will be passed into self.validate(value, **kwargs) and self.save(**kwargs).
-
load
()[源代码]¶ Takes the provided save data, validates it, and gets this Option ready to use.
- 返回
Boolean – Whether loading was successful.
-
save
(**kwargs)[源代码]¶ Stores the current value using .handler.save_handler(self.key, value, **kwargs) where kwargs are a combination of those passed into this function and the ones specified by the OptionHandler.
- 关键字参数
any (any) – Not used by default. These are passed in from self.set and allows the option to let the caller customize saving by overriding or extend the default save kwargs
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
serialize
()[源代码]¶ Serializes the save data for Attribute storage.
- 返回
any (any) – Whatever is best for storage.
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
class
evennia.utils.optionclasses.
Text
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Email
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Boolean
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
display
(**kwargs)[源代码]¶ Renders the Option’s value as something pretty to look at.
- 关键字参数
any (any) – These are options passed by the caller to potentially customize display dynamically.
- 返回
str –
- How the stored value should be projected to users (e.g. a raw
timedelta is pretty ugly).
-
serialize
()[源代码]¶ Serializes the save data for Attribute storage.
- 返回
any (any) – Whatever is best for storage.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Color
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
display
(**kwargs)[源代码]¶ Renders the Option’s value as something pretty to look at.
- 关键字参数
any (any) – These are options passed by the caller to potentially customize display dynamically.
- 返回
str –
- How the stored value should be projected to users (e.g. a raw
timedelta is pretty ugly).
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Timezone
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
property
default
¶
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
UnsignedInteger
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validator_key
= 'unsigned_integer'¶
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
SignedInteger
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
PositiveInteger
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Duration
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Datetime
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.BaseOption
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
deserialize
(save_data)[源代码]¶ Perform sanity-checking on the save data as it is loaded from storage. This isn’t the same as what validator-functions provide (those work on user input). For example, save data might be a timedelta or a list or some other object.
- 参数
save_data – The data to check.
- 返回
any (any) –
- Whatever the Option needs to track, like a string or a
datetime. The display hook is responsible for what is actually displayed to user.
-
-
class
evennia.utils.optionclasses.
Future
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.Datetime
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-
-
class
evennia.utils.optionclasses.
Lock
(handler, key, description, default)[源代码]¶ 基类:
evennia.utils.optionclasses.Text
-
validate
(value, **kwargs)[源代码]¶ Validate user input, which is presumed to be a string.
- 参数
value (str) – User input.
account (AccountDB) – The Account that is performing the validation. This is necessary because of other settings which may affect the check, such as an Account’s timezone affecting how their datetime entries are processed.
- 返回
any (any) – The results of the validation.
- 引发
ValidationError – If input value failed validation.
-