summaryrefslogtreecommitdiffstats
path: root/ipalib
diff options
context:
space:
mode:
authorJason Gerard DeRose <jderose@redhat.com>2008-10-18 00:16:22 -0600
committerJason Gerard DeRose <jderose@redhat.com>2008-10-18 00:16:22 -0600
commit5c5641e8c2e988dff8b81308775c048fb7178929 (patch)
tree4853a6fdb733c6354a867793d0eb5df4d29e7639 /ipalib
parent675fadc641ed6b521943c2c265bce70ac2c7994c (diff)
downloadfreeipa-5c5641e8c2e988dff8b81308775c048fb7178929.tar.gz
freeipa-5c5641e8c2e988dff8b81308775c048fb7178929.tar.xz
freeipa-5c5641e8c2e988dff8b81308775c048fb7178929.zip
Added some more examples to Param docstrings
Diffstat (limited to 'ipalib')
-rw-r--r--ipalib/frontend.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/ipalib/frontend.py b/ipalib/frontend.py
index af640cb59..d2985fa73 100644
--- a/ipalib/frontend.py
+++ b/ipalib/frontend.py
@@ -200,7 +200,7 @@ class Param(plugable.ReadOnly):
============ ================= ==================
cli_name str defaults to name
type ipa_type.Type ipa_type.Unicode()
- doc str ''
+ doc str ""
required bool True
multivalue bool False
primary_key bool False
@@ -305,6 +305,14 @@ class Param(plugable.ReadOnly):
"""
Normalize ``value`` using normalize callback.
+ For example:
+
+ >>> param = Param('telephone',
+ ... normalize=lambda value: value.replace('.', '-')
+ ... )
+ >>> param.normalize('800.123.4567')
+ '800-123-4567'
+
If this `Param` instance does not have a normalize callback,
``value`` is returned unchanged.
@@ -340,6 +348,14 @@ class Param(plugable.ReadOnly):
"""
Convert/coerce ``value`` to Python type for this `Param`.
+ For example:
+
+ >>> param = Param('an_int', type=ipa_types.Int())
+ >>> param.convert(7.2)
+ 7
+ >>> param.convert(" 7 ")
+ 7
+
If ``value`` can not be converted, ConversionError is raised, which
is as subclass of ValidationError.
@@ -413,6 +429,12 @@ class Param(plugable.ReadOnly):
return self.default
def get_values(self):
+ """
+ Return a tuple of possible values.
+
+ For enumerable types, a tuple containing the possible values is
+ returned. For all other types, an empty tuple is returned.
+ """
if self.type.name in ('Enum', 'CallbackEnum'):
return self.type.values
return tuple()