Other Property Types

StringChoice

class properties.StringChoice(doc, choices, case_sensitive=False, **kwargs)[source]

String Property where only certain choices are allowed

Available keywords (in addition to those inherited from Property):

  • choices - Either a set/list/tuple of allowed strings OR a dictionary of string key and list-of-string value pairs, where any string in the value list is coerced to the key string.
  • case_sensitive - Determine if input must follow case in choices. If False (the default), the input value will be coerced to the case in choices.
  • descriptions - Dictionary of choice/description key/value pairs. If specified, it must contain all choices.

Color

class properties.Color(doc, **kwargs)[source]

Property for RGB colors.

Valid inputs are length-3 RGB tuple/list with integer values between 0 and 255, 3 or 6 digit hex color, color name from standard web colors, or ‘random’. All of these are coerced to RGB tuple.

No additional keywords are avalaible besides those those inherited from Property.

DateTime

class properties.DateTime(doc, **kwargs)[source]

Property for DateTimes

This property uses datetime.datetime. The value may also be specified as a string that uses either ‘1995/08/12’ or ‘1995-08-12T18:00:00Z’ format; these are coerced to a datetime instance.

No additional keywords are avalaible besides those those inherited from Property.

File

class properties.File(doc, mode=None, **kwargs)[source]

Property for files

This may be a file or file-like object. If mode is provided, filenames are also allowed; these will be opened on validate. Note: Validation rejects closed files, but nothing prevents the file from being modified or closed once it is set.

Available keywords (in addition to those inherited from Property):

  • mode: Opens the file in this mode. If ‘r’ or ‘rb’, the file must exist, otherwise the file will be created. If None, string filenames will not be open (and therefore be invalid). Default value is None.
  • valid_modes: Tuple of valid modes for open files. This must include mode. If nothing is specified, valid_mode is set to mode.