baserlib: Make "_OPCODE_ATTRS" public
authorMichael Hanselmann <hansmi@google.com>
Thu, 14 Feb 2013 16:44:25 +0000 (17:44 +0100)
committerMichael Hanselmann <hansmi@google.com>
Tue, 19 Feb 2013 16:57:38 +0000 (17:57 +0100)
"_OPCODE_ATTRS" will also be used in the Sphinx extension.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>

lib/rapi/baserlib.py
test/py/ganeti.rapi.baserlib_unittest.py

index 4b6cc89..0edd96b 100644 (file)
@@ -59,7 +59,7 @@ def _BuildOpcodeAttributes():
           for method in _SUPPORTED_METHODS]
 
 
-_OPCODE_ATTRS = _BuildOpcodeAttributes()
+OPCODE_ATTRS = _BuildOpcodeAttributes()
 
 
 def BuildUriList(ids, uri_format, uri_fields=("name", "uri")):
@@ -403,7 +403,7 @@ def GetResourceOpcodes(cls):
 
   """
   return frozenset(filter(None, (getattr(cls, op_attr, None)
-                                 for (_, op_attr, _, _) in _OPCODE_ATTRS)))
+                                 for (_, op_attr, _, _) in OPCODE_ATTRS)))
 
 
 def GetHandlerAccess(handler, method):
@@ -428,7 +428,7 @@ class _MetaOpcodeResource(type):
     # Access to private attributes of a client class, pylint: disable=W0212
     obj = type.__call__(mcs, *args, **kwargs)
 
-    for (method, op_attr, rename_attr, fn_attr) in _OPCODE_ATTRS:
+    for (method, op_attr, rename_attr, fn_attr) in OPCODE_ATTRS:
       if hasattr(obj, method):
         # If the method handler is already defined, "*_RENAME" or "Get*OpInput"
         # shouldn't be (they're only used by the automatically generated
index 0582cb7..00c9678 100755 (executable)
@@ -109,14 +109,14 @@ class TestOpcodeResource(unittest.TestCase):
     attrs = ["%s_OPCODE" % method, "%s_RENAME" % method,
              "Get%sOpInput" % method.capitalize()]
     assert attrs == dict((opattrs[0], list(opattrs[1:]))
-                         for opattrs in baserlib._OPCODE_ATTRS)[method]
+                         for opattrs in baserlib.OPCODE_ATTRS)[method]
     return attrs
 
   def test(self):
     for method in baserlib._SUPPORTED_METHODS:
       # Empty handler
       obj = self._MakeClass(method, {})(None, None, None)
-      for attr in itertools.chain(*baserlib._OPCODE_ATTRS):
+      for attr in itertools.chain(*baserlib.OPCODE_ATTRS):
         self.assertFalse(hasattr(obj, attr))
 
       # Direct handler function
@@ -153,7 +153,7 @@ class TestOpcodeResource(unittest.TestCase):
 
     obj = _Empty(None, None, None)
 
-    for attr in itertools.chain(*baserlib._OPCODE_ATTRS):
+    for attr in itertools.chain(*baserlib.OPCODE_ATTRS):
       self.assertFalse(hasattr(obj, attr))