mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-23 07:33:27 -06:00
Allow one-character Param names
This is done explicitly to support the l/localityname attribute.
This commit is contained in:
parent
b31f259b1a
commit
338578d10a
@ -216,7 +216,7 @@ def check_name(name):
|
|||||||
>>> check_name('MyName')
|
>>> check_name('MyName')
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'MyName'
|
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$|^[a-z]$'; got 'MyName'
|
||||||
|
|
||||||
Also, this function will raise a ``TypeError`` if ``name`` is not an
|
Also, this function will raise a ``TypeError`` if ``name`` is not an
|
||||||
``str`` instance. For example:
|
``str`` instance. For example:
|
||||||
|
@ -74,11 +74,11 @@ class Env(object):
|
|||||||
>>> env.BadName = 'Wont work as an attribute'
|
>>> env.BadName = 'Wont work as an attribute'
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'BadName'
|
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$|^[a-z]$'; got 'BadName'
|
||||||
>>> env['BadName'] = 'Also wont work as a dictionary item'
|
>>> env['BadName'] = 'Also wont work as a dictionary item'
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'BadName'
|
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$|^[a-z]$'; got 'BadName'
|
||||||
|
|
||||||
The variable values can be ``str``, ``int``, or ``float`` instances, or the
|
The variable values can be ``str``, ``int``, or ``float`` instances, or the
|
||||||
``True``, ``False``, or ``None`` constants. When the value provided is an
|
``True``, ``False``, or ``None`` constants. When the value provided is an
|
||||||
|
@ -26,7 +26,7 @@ All constants centralised in one file.
|
|||||||
NULLS = (None, '', u'', tuple(), [])
|
NULLS = (None, '', u'', tuple(), [])
|
||||||
|
|
||||||
# regular expression NameSpace member names must match:
|
# regular expression NameSpace member names must match:
|
||||||
NAME_REGEX = r'^[a-z][_a-z0-9]*[a-z0-9]$'
|
NAME_REGEX = r'^[a-z][_a-z0-9]*[a-z0-9]$|^[a-z]$'
|
||||||
|
|
||||||
# Format for ValueError raised when name does not match above regex:
|
# Format for ValueError raised when name does not match above regex:
|
||||||
NAME_ERROR = 'name must match %r; got %r'
|
NAME_ERROR = 'name must match %r; got %r'
|
||||||
|
@ -192,10 +192,6 @@ def parse_param_spec(spec):
|
|||||||
raise TypeError(
|
raise TypeError(
|
||||||
TYPE_ERROR % ('spec', str, spec, type(spec))
|
TYPE_ERROR % ('spec', str, spec, type(spec))
|
||||||
)
|
)
|
||||||
if len(spec) < 2:
|
|
||||||
raise ValueError(
|
|
||||||
'spec must be at least 2 characters; got %r' % spec
|
|
||||||
)
|
|
||||||
_map = {
|
_map = {
|
||||||
'?': dict(required=False, multivalue=False),
|
'?': dict(required=False, multivalue=False),
|
||||||
'*': dict(required=False, multivalue=True),
|
'*': dict(required=False, multivalue=True),
|
||||||
|
@ -134,10 +134,6 @@ def test_parse_param_spec():
|
|||||||
e = raises(TypeError, f, u'name?')
|
e = raises(TypeError, f, u'name?')
|
||||||
assert str(e) == TYPE_ERROR % ('spec', str, u'name?', unicode)
|
assert str(e) == TYPE_ERROR % ('spec', str, u'name?', unicode)
|
||||||
|
|
||||||
# Test that ValueError is raised if len(spec) < 2:
|
|
||||||
e = raises(ValueError, f, 'n')
|
|
||||||
assert str(e) == "spec must be at least 2 characters; got 'n'"
|
|
||||||
|
|
||||||
|
|
||||||
class DummyRule(object):
|
class DummyRule(object):
|
||||||
def __init__(self, error=None):
|
def __init__(self, error=None):
|
||||||
|
Loading…
Reference in New Issue
Block a user