/usr/lib/python2.7/dist-packages/maasserver/utils/forms.py is in python-django-maas 1.5+bzr2252-0ubuntu1.
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 | # Copyright 2014 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Form utilities."""
from __future__ import (
absolute_import,
print_function,
unicode_literals,
)
str = None
__metaclass__ = type
__all__ = [
'compose_invalid_choice_text',
]
def compose_invalid_choice_text(choice_of_what, valid_choices):
"""Compose an "invalid choice" string for form error messages.
This returns a template string that is intended to be used as the
argument to the 'error_messages' parameter in a Django form.
:param choice_of_what: The name for what the selected item is supposed
to be, to be inserted into the error string.
:type choice_of_what: unicode
:param valid_choices: Valid choices, in Django choices format:
(name, value).
:type valid_choices: sequence
"""
return "'%s' is not a valid %s. It should be one of: %s." % (
"%(value)s",
choice_of_what,
", ".join("'%s'" % name for name, value in valid_choices),
)
|