Revision c3a5176f
b/lib/rapi/baserlib.py | ||
---|---|---|
59 | 59 |
for method in _SUPPORTED_METHODS] |
60 | 60 |
|
61 | 61 |
|
62 |
_OPCODE_ATTRS = _BuildOpcodeAttributes()
|
|
62 |
OPCODE_ATTRS = _BuildOpcodeAttributes() |
|
63 | 63 |
|
64 | 64 |
|
65 | 65 |
def BuildUriList(ids, uri_format, uri_fields=("name", "uri")): |
... | ... | |
403 | 403 |
|
404 | 404 |
""" |
405 | 405 |
return frozenset(filter(None, (getattr(cls, op_attr, None) |
406 |
for (_, op_attr, _, _) in _OPCODE_ATTRS)))
|
|
406 |
for (_, op_attr, _, _) in OPCODE_ATTRS))) |
|
407 | 407 |
|
408 | 408 |
|
409 | 409 |
def GetHandlerAccess(handler, method): |
... | ... | |
428 | 428 |
# Access to private attributes of a client class, pylint: disable=W0212 |
429 | 429 |
obj = type.__call__(mcs, *args, **kwargs) |
430 | 430 |
|
431 |
for (method, op_attr, rename_attr, fn_attr) in _OPCODE_ATTRS:
|
|
431 |
for (method, op_attr, rename_attr, fn_attr) in OPCODE_ATTRS: |
|
432 | 432 |
if hasattr(obj, method): |
433 | 433 |
# If the method handler is already defined, "*_RENAME" or "Get*OpInput" |
434 | 434 |
# shouldn't be (they're only used by the automatically generated |
b/test/py/ganeti.rapi.baserlib_unittest.py | ||
---|---|---|
109 | 109 |
attrs = ["%s_OPCODE" % method, "%s_RENAME" % method, |
110 | 110 |
"Get%sOpInput" % method.capitalize()] |
111 | 111 |
assert attrs == dict((opattrs[0], list(opattrs[1:])) |
112 |
for opattrs in baserlib._OPCODE_ATTRS)[method]
|
|
112 |
for opattrs in baserlib.OPCODE_ATTRS)[method] |
|
113 | 113 |
return attrs |
114 | 114 |
|
115 | 115 |
def test(self): |
116 | 116 |
for method in baserlib._SUPPORTED_METHODS: |
117 | 117 |
# Empty handler |
118 | 118 |
obj = self._MakeClass(method, {})(None, None, None) |
119 |
for attr in itertools.chain(*baserlib._OPCODE_ATTRS):
|
|
119 |
for attr in itertools.chain(*baserlib.OPCODE_ATTRS): |
|
120 | 120 |
self.assertFalse(hasattr(obj, attr)) |
121 | 121 |
|
122 | 122 |
# Direct handler function |
... | ... | |
153 | 153 |
|
154 | 154 |
obj = _Empty(None, None, None) |
155 | 155 |
|
156 |
for attr in itertools.chain(*baserlib._OPCODE_ATTRS):
|
|
156 |
for attr in itertools.chain(*baserlib.OPCODE_ATTRS): |
|
157 | 157 |
self.assertFalse(hasattr(obj, attr)) |
158 | 158 |
|
159 | 159 |
|
Also available in: Unified diff