diff mbox series

[v3,11/17] qapi: centralize the built-in module name definition

Message ID 20210119180242.1570753-12-jsnow@redhat.com (mailing list archive)
State New, archived
Headers show
Series qapi: static typing conversion, pt1.5 | expand

Commit Message

John Snow Jan. 19, 2021, 6:02 p.m. UTC
Use a constant to make it obvious we're referring to a very specific thing.

Signed-off-by: John Snow <jsnow@redhat.com>
---
 scripts/qapi/schema.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/scripts/qapi/schema.py b/scripts/qapi/schema.py
index c519c18a5ec..887a1c82c6f 100644
--- a/scripts/qapi/schema.py
+++ b/scripts/qapi/schema.py
@@ -68,7 +68,7 @@  def check_doc(self):
 
     def _set_module(self, schema, info):
         assert self._checked
-        fname = info.fname if info else './builtin'
+        fname = info.fname if info else QAPISchemaModule.BUILTIN_MODULE_NAME
         self._module = schema.module_by_fname(fname)
         self._module.add_entity(self)
 
@@ -138,6 +138,9 @@  def visit_event(self, name, info, ifcond, features, arg_type, boxed):
 
 
 class QAPISchemaModule:
+
+    BUILTIN_MODULE_NAME = './builtin'
+
     def __init__(self, name):
         self.name = name
         self._entity_list = []
@@ -152,7 +155,7 @@  def is_user_module(cls, name: str) -> bool:
 
     @classmethod
     def is_builtin_module(cls, name: str) -> bool:
-        return name == './builtin'
+        return name == cls.BUILTIN_MODULE_NAME
 
     @property
     def system_module(self) -> bool:
@@ -850,7 +853,7 @@  def __init__(self, fname):
         self._entity_dict = {}
         self._module_dict = OrderedDict()
         self._schema_dir = os.path.dirname(fname)
-        self._make_module('./builtin')  # built-ins
+        self._make_module(QAPISchemaModule.BUILTIN_MODULE_NAME)  # built-ins
         self._make_module(fname)
         self._predefining = True
         self._def_predefineds()