evennia.utils.validatorfuncs

Contains all the validation functions.

All validation functions must have a checker (probably a session) and entry arg.

They can employ more paramters at your leisure.

evennia.utils.validatorfuncs.text(entry, option_key='Text', **kwargs)[源代码]
evennia.utils.validatorfuncs.color(entry, option_key='Color', **kwargs)[源代码]

The color should be just a color character, so ‘r’ if red color is desired.

evennia.utils.validatorfuncs.datetime(entry, option_key='Datetime', account=None, from_tz=None, **kwargs)[源代码]

Process a datetime string in standard forms while accounting for the inputer’s timezone. Always returns a result in UTC.

参数
  • entry (str) – A date string from a user.

  • option_key (str) – Name to display this datetime as.

  • account (AccountDB) – The Account performing this lookup. Unless from_tz is provided, the account’s timezone option will be used.

  • from_tz (pytz.timezone) – An instance of a pytz timezone object from the user. If not provided, tries to use the timezone option of account. If neither one is provided, defaults to UTC.

返回

datetime in UTC.

引发

ValueError – If encountering a malformed timezone, date string or other format error.

evennia.utils.validatorfuncs.duration(entry, option_key='Duration', **kwargs)[源代码]

Take a string and derive a datetime timedelta from it.

参数
  • entry (string) – This is a string from user-input. The intended format is, for example: “5d 2w 90s” for ‘five days, two weeks, and ninety seconds.’ Invalid sections are ignored.

  • option_key (str) – Name to display this query as.

返回

timedelta

evennia.utils.validatorfuncs.future(entry, option_key='Future Datetime', from_tz=None, **kwargs)[源代码]
evennia.utils.validatorfuncs.signed_integer(entry, option_key='Signed Integer', **kwargs)[源代码]
evennia.utils.validatorfuncs.positive_integer(entry, option_key='Positive Integer', **kwargs)[源代码]
evennia.utils.validatorfuncs.unsigned_integer(entry, option_key='Unsigned Integer', **kwargs)[源代码]
evennia.utils.validatorfuncs.boolean(entry, option_key='True/False', **kwargs)[源代码]

Simplest check in computer logic, right? This will take user input to flick the switch on or off

参数
  • entry (str) – A value such as True, On, Enabled, Disabled, False, 0, or 1.

  • option_key (str) – What kind of Boolean we are setting. What Option is this for?

返回

Boolean

evennia.utils.validatorfuncs.timezone(entry, option_key='Timezone', **kwargs)[源代码]

Takes user input as string, and partial matches a Timezone.

参数
  • entry (str) – The name of the Timezone.

  • option_key (str) – What this Timezone is used for.

返回

A PYTZ timezone.

evennia.utils.validatorfuncs.email(entry, option_key='Email Address', **kwargs)[源代码]
evennia.utils.validatorfuncs.lock(entry, option_key='locks', access_options=None, **kwargs)[源代码]