/usr/lib/python2.7/dist-packages/formencode/interfaces.py is in python-formencode 1.3.0-0ubuntu5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | """
Interfaces for FormEncode (for documentation purposes only)
"""
class Attribute(object):
def __init__(self, description, name=None):
self.description = description
self.name = name
class Interface(object):
pass
class IDeclarative(Interface):
def __init__(**kw):
"""
Instantiates this class with all the keywords being used to
update the instance variables.
"""
def __call__(**kw):
"""
Returns a copy with all attributes using the given keywords,
being updated.
"""
class IValidator(IDeclarative):
messages = Attribute("""
A dictionary of messages (with formatting strings) for error
responses""", name='messages')
if_missing = Attribute("""
If the source that this validator would handle is missing (e.g.,
a field that was not specified), use this value. If
Validator.NoDefault, then if the field is missing an exception
should be raised.""", name='ifMissing')
repeating = Attribute("""
A boolean; this object accepts lists if true, subvalidators can be
found in the validators attribute.""", name='repeating')
compound = Attribute("""
A boolean; this object has a dictionary of validators if this is
true, subvalidators can be found in the field attribute (a
dictionary).""", name='compound')
def to_python(value, state=None):
"""
Convert `value` from its foreign representation to its Python
representation. `state` is for application-specific hooks.
"""
def from_python(value, state=None):
"""
Convert `value` from its Python representation to the foreign
representation. `state` is for application-specific hooks.
"""
def message(name, default):
"""
Return the message (from the `messages` attribute) that goes
with `name`, or return default if `name` not found `default`.
"""
class ISchema(IValidator):
fields = Attribute('A dictionary of (field name: validator)',
name='fields')
|