Commits

Armin Rigo  committed 595bfa0

Add the 'pyexpat.model' module.

  • Participants
  • Parent commits 668adc4

Comments (0)

Files changed (3)

File pypy/module/pyexpat/__init__.py

 
 class ErrorsModule(MixedModule):
     "Definition of pyexpat.errors module."
-
-    appleveldefs = {
-        }
-
-    interpleveldefs = {
-        }
+    appleveldefs = {}
+    interpleveldefs = {}
 
     def setup_after_space_initialization(self):
         from pypy.module.pyexpat import interp_pyexpat
                     interp_pyexpat.ErrorString(self.space,
                     getattr(interp_pyexpat, name)))
 
+class ModelModule(MixedModule):
+    "Definition of pyexpat.model module."
+    appleveldefs = {}
+    interpleveldefs = {}
+
+    def setup_after_space_initialization(self):
+        from pypy.module.pyexpat import interp_pyexpat
+        space = self.space
+        for name in interp_pyexpat.xml_model_list:
+            value = getattr(interp_pyexpat, name)
+            space.setattr(self, space.wrap(name), space.wrap(value))
+
 class Module(MixedModule):
     "Python wrapper for Expat parser."
 
 
     submodules = {
         'errors': ErrorsModule,
+        'model':  ModelModule,
     }
 
     for name in ['XML_PARAM_ENTITY_PARSING_NEVER',

File pypy/module/pyexpat/interp_pyexpat.py

     "XML_ERROR_FINISHED",
     "XML_ERROR_SUSPEND_PE",
     ]
+xml_model_list = [
+    "XML_CTYPE_EMPTY",
+    "XML_CTYPE_ANY",
+    "XML_CTYPE_MIXED",
+    "XML_CTYPE_NAME",
+    "XML_CTYPE_CHOICE",
+    "XML_CTYPE_SEQ",
+    "XML_CQUANT_NONE",
+    "XML_CQUANT_OPT",
+    "XML_CQUANT_REP",
+    "XML_CQUANT_PLUS",
+    ]
 
 class CConfigure:
     _compilation_info_ = eci
 
     for name in xml_error_list:
         locals()[name] = rffi_platform.ConstantInteger(name)
+    for name in xml_model_list:
+        locals()[name] = rffi_platform.ConstantInteger(name)
 
 for k, v in rffi_platform.configure(CConfigure).items():
     globals()[k] = v

File pypy/module/pyexpat/test/test_parser.py

                'encoding specified in XML declaration is incorrect')
         assert (pyexpat.errors.XML_ERROR_XML_DECL ==
                 'XML declaration not well-formed')
+
+    def test_model(self):
+        import pyexpat
+        assert isinstance(pyexpat.model.XML_CTYPE_EMPTY, int)