diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-13 01:07:33 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2009-01-13 01:07:33 -0700 |
commit | c2b0d03f82f16debcc55d34ac44197e0bc97e0e8 (patch) | |
tree | 9b49474abcaad206ef47368d33dce3aa3bf50e3a /ipalib/parameter.py | |
parent | 33db9fee6017c0777f4fc5da8b020aefd714e387 (diff) | |
download | freeipa.git-c2b0d03f82f16debcc55d34ac44197e0bc97e0e8.tar.gz freeipa.git-c2b0d03f82f16debcc55d34ac44197e0bc97e0e8.tar.xz freeipa.git-c2b0d03f82f16debcc55d34ac44197e0bc97e0e8.zip |
New Param: updated Bytes and Str length rules to use new rule(_, value) calling signature; updated corresponding unit tests
Diffstat (limited to 'ipalib/parameter.py')
-rw-r--r-- | ipalib/parameter.py | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/ipalib/parameter.py b/ipalib/parameter.py index 1c88d286..dbf75298 100644 --- a/ipalib/parameter.py +++ b/ipalib/parameter.py @@ -618,7 +618,7 @@ class Float(Param): class Bytes(Param): """ - + A parameter for binary data. """ type = str @@ -670,45 +670,40 @@ class Bytes(Param): """ return value - def _rule_minlength(self, _, name, value): + def _rule_minlength(self, _, value): """ Check minlength constraint. """ assert type(value) is str if len(value) < self.minlength: - return _('%(name)s must be at least %(minlength)d bytes') % dict( - name=name, + return _('must be at least %(minlength)d bytes') % dict( minlength=self.minlength, ) - def _rule_maxlength(self, _, name, value): + def _rule_maxlength(self, _, value): """ Check maxlength constraint. """ assert type(value) is str if len(value) > self.maxlength: - return _('%(name)s can be at most %(maxlength)d bytes') % dict( - name=name, + return _('can be at most %(maxlength)d bytes') % dict( maxlength=self.maxlength, ) - def _rule_length(self, _, name, value): + def _rule_length(self, _, value): """ Check length constraint. """ assert type(value) is str if len(value) != self.length: - return _('%(name)s must be exactly %(length)d bytes') % dict( - name=name, + return _('must be exactly %(length)d bytes') % dict( length=self.length, ) - - class Str(Bytes): """ - + A parameter for character (textual) data. """ type = unicode @@ -724,36 +719,33 @@ class Str(Bytes): 'Can only implicitly convert int, float, or bool; got %r' % value ) - def _rule_minlength(self, _, name, value): + def _rule_minlength(self, _, value): """ Check minlength constraint. """ assert type(value) is unicode if len(value) < self.minlength: - return _('%(name)s must be at least %(minlength)d characters') % dict( - name=name, + return _('must be at least %(minlength)d characters') % dict( minlength=self.minlength, ) - def _rule_maxlength(self, _, name, value): + def _rule_maxlength(self, _, value): """ Check maxlength constraint. """ assert type(value) is unicode if len(value) > self.maxlength: - return _('%(name)s can be at most %(maxlength)d characters') % dict( - name=name, + return _('can be at most %(maxlength)d characters') % dict( maxlength=self.maxlength, ) - def _rule_length(self, _, name, value): + def _rule_length(self, _, value): """ Check length constraint. """ assert type(value) is unicode if len(value) != self.length: - return _('%(name)s must be exactly %(length)d characters') % dict( - name=name, + return _('must be exactly %(length)d characters') % dict( length=self.length, ) |