Ejemplo n.º 1
0
 def test_declare(self):
     class_map = {}
     structures.map_class_elements(class_map, Elements)
     self.assertTrue(issubclass(class_map['mixed'], structures.Element),
                     "class type not declared")
     self.assertFalse(hasattr(class_map, 'bad'),
                      "class type declared by mistake")
Ejemplo n.º 2
0
 def test_declare(self):
     class_map = {}
     structures.map_class_elements(class_map, Elements)
     self.assertTrue(issubclass(class_map['mixed'], structures.Element),
                     "class type not declared")
     self.assertFalse(
         hasattr(class_map, 'bad'), "class type declared by mistake")
Ejemplo n.º 3
0
                                i = i + 1
                        annotation = metadata.LOMAnnotation()
                        annotationMsg = string.join(log, ';\n')
                        logging.info(annotationMsg)
                        description = annotation.add_child(
                            imsmd.Description)
                        description.add_child(
                            description.LangStringClass).set_value(annotationMsg)
                    r = doc.AddToContentPackage(cp, metadata, dName)
                    newResults.append((doc, metadata, log, r))
                cp.manifest.update()
            return newResults
        else:
            return []

xml.map_class_elements(QTIDocument.classMap, globals())


try:
    CNBIG5 = codecs.lookup('cn-big5')
    pass
except LookupError:
    CNBIG5 = None
    try:
        BIG5 = codecs.lookup('big5')
        CNBIG5 = codecs.CodecInfo(BIG5.encode, BIG5.decode, streamreader=BIG5.streamreader,
                                  streamwriter=BIG5.streamwriter, incrementalencoder=BIG5.incrementalencoder,
                                  incrementaldecoder=BIG5.incrementaldecoder, name='cn-big5')
    except LookupError:
        # we'll have to do without cn-big5
        pass
Ejemplo n.º 4
0
        yield self.QMLCondition
        yield self.QMLContent


class QMLCondition(QMLElement):
    XMLNAME = "CONDITION"
    XMLCONTENT = xml.XMLMixedContent


class QMLDocument(xml.Document):
    """Class for working with QML documents."""
    def __init__(self, **args):
        """"""
        xml.Document.__init__(self, **args)

    classMap = {}
    """classMap is a mapping from element names to the class object that will be
	used to represent them."""

    def get_element_class(self, name):
        """Returns the class to use to represent an element with the given name.

        This method is used by the XML parser.  The class object is looked up in
        :py:attr:`classMap`, if no specialized class is found then the general
        :py:class:`pyslet.xml.structures.Element` class is returned."""
        return QMLDocument.classMap.get(
            name, QMLDocument.classMap.get(None, xml.Element))


xml.map_class_elements(QMLDocument.classMap, globals())