Revision 4884f187 lib/ht.py
b/lib/ht.py | ||
---|---|---|
29 | 29 |
from ganeti import utils |
30 | 30 |
from ganeti import constants |
31 | 31 |
from ganeti import objects |
32 |
|
|
32 |
from ganeti.serializer import Private |
|
33 | 33 |
|
34 | 34 |
_PAREN_RE = re.compile("^[a-zA-Z0-9_-]+$") |
35 | 35 |
|
... | ... | |
77 | 77 |
def __str__(self): |
78 | 78 |
return self._text |
79 | 79 |
|
80 |
def __repr__(self): |
|
81 |
return "<%s %r>" % (self._text, self._fn) |
|
82 |
|
|
80 | 83 |
|
81 | 84 |
class _CommentWrapper(_WrapperBase): |
82 | 85 |
"""Wrapper class for comment. |
... | ... | |
269 | 272 |
def TDict(val): |
270 | 273 |
"""Checks if the given value is a dictionary. |
271 | 274 |
|
275 |
Note that L{PrivateDict}s subclass dict and pass this check. |
|
276 |
|
|
272 | 277 |
""" |
273 | 278 |
return isinstance(val, dict) |
274 | 279 |
|
... | ... | |
416 | 421 |
return desc(lambda val: isinstance(val, cls)) |
417 | 422 |
|
418 | 423 |
|
424 |
def TPrivate(val_type): |
|
425 |
"""Checks if a given value is an instance of Private. |
|
426 |
|
|
427 |
""" |
|
428 |
def fn(val): |
|
429 |
return isinstance(val, Private) and val_type(val.Get()) |
|
430 |
|
|
431 |
desc = WithDesc("Private %s" % Parens(val_type)) |
|
432 |
|
|
433 |
return desc(fn) |
|
434 |
|
|
435 |
|
|
419 | 436 |
def TListOf(my_type): |
420 | 437 |
"""Checks if a given value is a list with all elements of the same type. |
421 | 438 |
|
Also available in: Unified diff