示例#1
0
            self.root.SetAttribute((xsi.XMLSCHEMA_NAMESPACE, 'schemaLocation'),
                                   string.join(schemaLocation, ' '))

    def GetElementClass(self, name):
        """Overrides :py:meth:`pyslet.xmlnames20091208.XMLNSDocument.GetElementClass` to look up name.

        The class contains a mapping from (namespace,element name) pairs to
        class objects representing the elements.  Any element not in the class
        map returns :py:meth:`~pyslet.xmlnames20091208.XMLNSElement` instead."""
        eClass = ManifestDocument.classMap.get(
            name,
            ManifestDocument.classMap.get((name[0], None), xmlns.XMLNSElement))
        return eClass


xmlns.MapClassElements(ManifestDocument.classMap, globals())
xmlns.MapClassElements(ManifestDocument.classMap, imsmd)
xmlns.MapClassElements(ManifestDocument.classMap, qtimd)
# Add other supported metadata schemas in here


class ContentPackage:
    """Represents a content package.

    When constructed with no arguments a new package is created.  A temporary
    folder to hold the contents of the package is created and will not be
    cleaned up until the :py:meth:`Close` method is called.

    Alternatively, you can pass an operating system or virtual file path to a
    content package directory, to an imsmanifest.xml file or to a Package
    Interchange Format file.  In the latter case, the file is unzipped into a
示例#2
0
        core.QTIElement.__init__(self, parent)
        self.outcomeIdentifier = None
        self.showHide = None
        self.identifier = None
        self.title = None

    def ChildElement(self, childClass, name=None):
        if issubclass(childClass, html.FlowMixin):
            return core.QTIElement.ChildElement(self, childClass, name)
        else:
            # This child cannot go in here
            raise core.QTIValidityError(
                "%s in %s" % (repr(name), self.__class__.__name__))


xmlns.MapClassElements(core.QTIDocument.classMap, globals())
xmlns.MapClassElements(core.QTIDocument.classMap, variables)
xmlns.MapClassElements(core.QTIDocument.classMap, processing)
xmlns.MapClassElements(core.QTIDocument.classMap, content)
xmlns.MapClassElements(core.QTIDocument.classMap, interactions)
xmlns.MapClassElements(core.QTIDocument.classMap, items)
xmlns.MapClassElements(core.QTIDocument.classMap, tests)
xmlns.MapClassElements(core.QTIDocument.classMap, expressions)
xmlns.MapClassElements(core.QTIDocument.classMap, md)
# also add in the profile of HTML but with the namespace rewritten to ours
for name in QTI_HTMLProfile:
    eClass = html.XHTMLDocument.classMap.get(
        (html.XHTML_NAMESPACE, name), None)
    if eClass:
        core.QTIDocument.classMap[(core.IMSQTI_NAMESPACE, name)] = eClass
    else:
示例#3
0
                pass
        # DataServiceVersion: This attribute MUST be in the data service
        # metadata namespace and SHOULD be present on a <edmx:DataServices>
        # element to indicate the version of the data service CSDL
        # annotations (attributes in the data service metadata namespace)
        # used by the document.
        #
        # The value of this attribute MUST be 1.0 unless a
        # "FC_KeepInContent" Customizable Feed annotation with a value equal
        # to false is present... In this case, the attribute value MUST be
        # 2.0.
        try:
            version = self.root.DataServices.GetAttribute(DataServiceVersion)
            match = "1.0"
            for e in self.root.FindChildrenDepthFirst(edm.CSDLElement):
                try:
                    if e.GetAttribute(FC_KeepInContent) == "false":
                        match = "2.0"
                        break
                except KeyError:
                    pass
            if version != match:
                raise InvalidMetadataDocument("Expected version %s, found %s" %
                                              (match, version))
            return version
        except KeyError:
            return None


xmlns.MapClassElements(Document.classMap, globals(), edm.NAMESPACE_ALIASES)
示例#4
0
文件: rfc5023.py 项目: sassman/pyslet
    @classmethod
    def GetElementClass(cls, name):
        """Returns the APP or Atom class used to represent name.

        Overrides :py:meth:`~pyslet.rfc4287.AtomDocument.GetElementClass` when
        the namespace is :py:data:`APP_NAMESPACE`."""
        if name[0] == APP_NAMESPACE:
            return cls.classMap.get(
                name,
                atom.AtomDocument.classMap.get((name[0], None), APPElement))
        else:
            return atom.AtomDocument.GetElementClass(name)


xmlns.MapClassElements(Document.classMap, globals())


class Client(http.HTTPRequestManager):
    def __init__(self):
        http.HTTPRequestManager.__init__(self)

    def QueueRequest(self, request, timeout=60):
        # if there is no Accept header, add one
        if not request.HasHeader('Accept'):
            request.SetHeader(
                'Accept',
                string.join(
                    (atom.ATOM_MIMETYPE, ATOMSVC_MIMETYPE, ATOMCAT_MIMETYPE),
                    ','), True)
        super(Client, self).QueueRequest(request, timeout)
示例#5
0
        self.LOMPerson = None
        self.LOMDate = None
        self.Description = None

    def GetChildren(self):
        if self.LOMPerson:
            yield self.LOMPerson
        if self.LOMDate:
            yield self.LOMDate
        if self.Description:
            yield self.Description
        for child in LRMElement.GetChildren(self):
            yield child


class LOMClassification(LRMElement):
    XMLNAME = (IMSLRM_NAMESPACE, 'classification')


classMap = {(IMSLRM_NAMESPACE, None): LRMElement}

xmlns.MapClassElements(classMap, globals())


def get_element_class(name):
    ns, xmlname = name
    if ns in IMSLRM_NAMESPACE_ALIASES:
        ns = IMSLRM_NAMESPACE_ALIASES[ns]
    return classMap.get((ns, xmlname),
                        classMap.get((ns, None), xmlns.XMLNSElement))
示例#6
0
        self.MakePrefix(IMSCC_LOMMANIFEST_NAMESPACE, 'lomimscc')
        self.MakePrefix(IMSCC_LOMRESOURCE_NAMESPACE, 'lom')
        schemaLocation = [
            IMSCC_CP_NAMESPACE, IMSCC_CP_SCHEMALOCATION,
            IMSCC_LOMMANIFEST_NAMESPACE, IMSCC_LOMMANIFEST_SCHEMALOCATION,
            IMSCC_LOMRESOURCE_NAMESPACE, IMSCC_LOMRESOURCE_SCHEMALOCATION
        ]
        if isinstance(self.root, imscp.CPElement):
            self.root.SetAttribute((xsi.XMLSCHEMA_NAMESPACE, 'schemaLocation'),
                                   string.join(schemaLocation, ' '))

    def get_element_class(self, name):
        eClass = ManifestDocument.classMap.get(
            name,
            ManifestDocument.classMap.get((name[0], None), xmlns.XMLNSElement))
        return eClass


xmlns.MapClassElements(ManifestDocument.classMap, globals())
# xmlns.MapClassElements(ManifestDocument.classMap,imsmd)
# xmlns.MapClassElements(ManifestDocument.classMap,imsqti)
# Add other supported metadata schemas in here


class ContentPackage(imscp.ContentPackage):
    ManifestDocumentClass = ManifestDocument


class CommonCartridge(v1p0.CommonCartridge):
    ContentPackageClass = ContentPackage