当前位置: 首页>>代码示例>>Python>>正文


Python path.TempDirPath类代码示例

本文整理汇总了Python中exe.engine.path.TempDirPath的典型用法代码示例。如果您正苦于以下问题:Python TempDirPath类的具体用法?Python TempDirPath怎么用?Python TempDirPath使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TempDirPath类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: export

 def export(self, package):
     """ 
     Export SCORM package
     """
     outputDir = TempDirPath()
     styleFiles  = [self.styleDir/'..'/'base.css']
     styleFiles += [self.styleDir/'..'/'popup_bg.gif']
     styleFiles += self.styleDir.files("*.css")
     if "nav.css" in styleFiles:
         styleFiles.remove("nav.css")
     styleFiles += self.styleDir.files("*.jpg")
     styleFiles += self.styleDir.files("*.gif")
     styleFiles += self.styleDir.files("*.png")
     styleFiles += self.styleDir.files("*.js")
     styleFiles += self.styleDir.files("*.html")
     self.styleDir.copylist(styleFiles, outputDir)
     package.resourceDir.copyfiles(outputDir)
     self.pages = [ IMSPage("index", 1, package.root) ]
     self.generatePages(package.root, 2)
     uniquifyNames(self.pages)
     for page in self.pages:
         page.save(outputDir)
     manifest = Manifest(self.config, outputDir, package, self.pages)
     manifest.save()
     self.scriptsDir.copylist(('libot_drag.js',
                               'common.js'), outputDir)
     self.schemasDir.copylist(('imscp_v1p1.xsd',
                               'imsmd_v1p2p2.xsd',
                               'ims_xml.xsd'), outputDir)
     self.templatesDir.copylist(('videoContainer.swf', 'magnifier.swf',
                                 'xspf_player.swf'),outputDir)
     (self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
     self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
     outputDir.rmtree()
开发者ID:,项目名称:,代码行数:34,代码来源:

示例2: exportZip

    def exportZip(self, package):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        
        outputDir = TempDirPath()

        # Import the Website Page class.  If the style has it's own page class
        # use that, else use the default one.
        if (self.stylesDir/"websitepage.py").exists():
            global WebsitePage
            module = imp.load_source("websitepage", 
                                     self.stylesDir/"websitepage.py")
            WebsitePage = module.WebsitePage

        self.pages = [ WebsitePage("index", 1, package.root) ]
        self.generatePages(package.root, 1)
        uniquifyNames(self.pages)

        prevPage = None
        thisPage = self.pages[0]

        for nextPage in self.pages[1:]:
            thisPage.save(outputDir, prevPage, nextPage, self.pages)
            prevPage = thisPage
            thisPage = nextPage
            

        thisPage.save(outputDir, prevPage, None, self.pages)
        self.copyFiles(package, outputDir)
        # Zip up the website package
        self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
        # Clean up the temporary dir
        outputDir.rmtree()
开发者ID:kohnle-lernmodule,项目名称:palama,代码行数:35,代码来源:websiteexport.py

示例3: testExport

    def testExport(self):
        # Delete the output dir
        outdir = TempDirPath()
        
        G.application = Application()
        
        G.application.loadConfiguration()
        G.application.preLaunch()
        
        # Load a package
        package = Package.load('testing/testPackage2.elp')
        # Do the export
        style_dir = G.application.config.stylesDir / package.style
        
        exporter = WebsiteExport(G.application.config,
                                 style_dir, 
                                 outdir)
        
        exporter.export(package)
        # Check that it all exists now
        assert outdir.isdir()
        assert (outdir / 'index.html').isfile()
        # Check that the style sheets have been copied
        for filename in style_dir.files():
            assert ((outdir / filename.basename()).exists(),
                    'Style file "%s" not copied' % (outdir / filename.basename()))

        # Check that each node in the package has had a page made
        pagenodes  = Set([p.node for p in exporter.pages])
        othernodes = Set(self._getNodes([], package.root))
        assert pagenodes == othernodes

        for page in exporter.pages:
            self._testPage(page, outdir)
开发者ID:Rafav,项目名称:iteexe,代码行数:34,代码来源:testexport.py

示例4: exportZip

    def exportZip(self, package):
	""" 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
	
	outputDir = TempDirPath()
        self.copyFiles(package, outputDir)
        if (self.stylesDir/"websitepage.py").exists():
            global WebsitePage
            module = imp.load_source("websitepage", 
                                     self.stylesDir/"websitepage.py")
            WebsitePage = module.WebsitePage
        self.pages = [ WebsitePage("index", 1, package.root) ]
        self.generatePages(package.root, 1)
        uniquifyNames(self.pages)
        prevPage = None
        thisPage = self.pages[0]
        for nextPage in self.pages[1:]:
            thisPage.save(outputDir, prevPage, nextPage, self.pages)
            prevPage = thisPage
            thisPage = nextPage
        thisPage.save(outputDir, prevPage, None, self.pages)
	
        zipped = ZipFile(self.filename, "w")
        for scormFile in outputDir.files():
            zipped.write(scormFile,
                         scormFile.basename().encode('utf8'),
                         ZIP_DEFLATED)
        zipped.close()
        outputDir.rmtree()
开发者ID:,项目名称:,代码行数:31,代码来源:

示例5: __init__

    def __init__(self, name):
        """
        Initialize 
        """
        log.debug(u"init " + repr(name))
        self._nextIdeviceId = 0
        self._nextNodeId = 0
        # For looking up nodes by ids
        self._nodeIdDict = {}

        self._levelNames = self.defaultLevelNames[:]
        self.name = name
        self._title = u""
        self._backgroundImg = u""
        self.backgroundImgTile = False

        # Empty if never saved/loaded
        self.filename = u""

        self.root = Node(self, None, _(u"Home"))
        self.currentNode = self.root
        self.style = u"default"
        self.isChanged = False
        self.idevices = []
        self.dublinCore = DublinCore()
        self.scolinks = False
        self.license = "None"
        self.footer = ""

        # Temporary directory to hold resources in
        self.resourceDir = TempDirPath()
        self.resources = {}  # Checksum-[_Resource(),..]
开发者ID:kohnle-lernmodule,项目名称:exeLearningPlus1_04,代码行数:32,代码来源:package.py

示例6: __init__

 def __init__(self, name):
     """
     Initialize 
     """
     log.debug(u"init " + repr(name))
     self._nextIdeviceId = 0
     self._nextNodeId    = 0
     self._nodeIdDict    = {} 
     self._levelNames    = self.defaultLevelNames[:]
     self.name           = name
     self._title         = u''
     self._backgroundImg = u''
     self.backgroundImgTile = False
     self.filename      = u''
     self.root          = Node(self, None, _(u"Home"))
     self.currentNode   = self.root
     self.style         = u"default"
     self.isChanged     = False
     self.idevices      = []
     self.dublinCore    = DublinCore()
     self.scolinks      = False
     self.license       = "None"
     self.footer        = ""
     self.resourceDir = TempDirPath()
     self.resources = {} # Checksum-[_Resource(),..]
开发者ID:,项目名称:,代码行数:25,代码来源:

示例7: testExport

 def testExport(self):
     outdir = TempDirPath()
     package = Package.load('testPackage.elp')
     exporter = WebsiteExport('../exe/webui/style/default', 
                              outdir,
                              '../exe/webui/images', 
                              '../exe/webui/scripts',
                              '../exe/webui/templates')
     exporter.export(package)
     assert outdir.isdir()
     assert (outdir / 'index.html').isfile()
     for filename in Path('../exe/webui/style/default').files():
         assert ((outdir / filename.basename()).exists(),
                 'Style file "%s" not copied' % (outdir / filename.basename()))
     pagenodes  = Set([p.node for p in exporter.pages])
     othernodes = Set(self._getNodes([], package.root))
     assert pagenodes == othernodes
     for page in exporter.pages:
         self._testPage(page, outdir)
开发者ID:,项目名称:,代码行数:19,代码来源:

示例8: export

    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)

        # copy the package's resource files, only non existant in outputDir
        #        outputDirFiles = outputDir.files()
        #        for rfile in package.resourceDir.files():
        #            if rfile not in outputDirFiles:
        #                rfile.copy(outputDir)

        # copy the package's resource files, only indexed in package.resources
        #        for md5 in package.resources.values():
        #            for resource in md5:
        #                resource.path.copy(outputDir)

        # Export the package content
        # Import the Scorm Page class , if the secure mode is off.  If the style has it's own page class
        # use that, else use the default one.
        if self.styleSecureMode == "0":
            if (self.styleDir / "scormpage.py").exists():
                global ScormPage
                module = imp.load_source("ScormPage", self.styleDir / "scormpage.py")
                ScormPage = module.ScormPage

        self.pages = [ScormPage("index", 1, package.root, scormType=self.scormType, metadataType=self.metadataType)]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)
            if not self.hasForum:
                for idevice in page.node.idevices:
                    if hasattr(idevice, "isForum"):
                        if idevice.forum.lms.lms == "moodle":
                            self.hasForum = True
                            break

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
        manifest.save("imsmanifest.xml")
        if self.hasForum:
            manifest.save("discussionforum.xml")

        # Copy the style sheet files to the output dir
        styleFiles = [self.styleDir / ".." / "base.css"]
        styleFiles += [self.styleDir / ".." / "popup_bg.gif"]
        # And with all the files of the style we avoid problems:
        styleFiles += self.styleDir.files("*.*")
        if self.scormType == "commoncartridge":
            for sf in styleFiles[:]:
                if sf.basename() not in manifest.dependencies:
                    styleFiles.remove(sf)
        self.styleDir.copylist(styleFiles, outputDir)

        # Copy the scripts
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = self.scriptsDir / "exe_html5.js"
            jsFile.copyfile(outputDir / "exe_html5.js")

        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = self.scriptsDir / "exe_jquery.js"
                jsFile.copyfile(outputDir / "exe_jquery.js")
        else:
            jsFile = self.scriptsDir / "exe_jquery.js"
            jsFile.copyfile(outputDir / "exe_jquery.js")

        if self.scormType == "commoncartridge":
            jsFile = self.scriptsDir / "common.js"
            jsFile.copyfile(outputDir / "common.js")

        if self.scormType == "scorm2004" or self.scormType == "scorm1.2":
            self.scriptsDir.copylist(("SCORM_API_wrapper.js", "SCOFunctions.js", "common.js"), outputDir)
        # about SCHEMAS:
        schemasDir = ""
        if self.scormType == "scorm1.2":
            schemasDir = self.schemasDir / "scorm1.2"
            schemasDir.copylist(
                (
                    "imscp_rootv1p1p2.xsd",
                    "imsmd_rootv1p2p1.xsd",
                    "adlcp_rootv1p2.xsd",
                    "lom.xsd",
                    "lomCustom.xsd",
                    "ims_xml.xsd",
                ),
                outputDir,
            )
#.........这里部分代码省略.........
开发者ID:RichDijk,项目名称:eXe,代码行数:101,代码来源:scormexport.py

示例9: export

    def export(self, package):
        """
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType

        # copy the package's resource files
        for resourceFile in package.resourceDir.walkfiles():
            file = package.resourceDir.relpathto(resourceFile)

            if ("/" in file):
                Dir = Path(outputDir/file[:file.rindex("/")])

                if not Dir.exists():
                    Dir.makedirs()

                resourceFile.copy(outputDir/Dir)
            else:
                resourceFile.copy(outputDir)

        # copy the package's resource files, only non existant in outputDir
#        outputDirFiles = outputDir.files()
#        for rfile in package.resourceDir.files():
#            if rfile not in outputDirFiles:
#                rfile.copy(outputDir)

        # copy the package's resource files, only indexed in package.resources
#        for md5 in package.resources.values():
#            for resource in md5:
#                resource.path.copy(outputDir)

        # Export the package content
        # Import the Scorm Page class , if the secure mode is off.  If the style has it's own page class
        # use that, else use the default one.
        if self.styleSecureMode=="0":
            if (self.styleDir/"scormpage.py").exists():
                global ScormPage
                module = imp.load_source("ScormPage",self.styleDir/"scormpage.py")
                ScormPage = module.ScormPage


        self.pages = [ ScormPage("index", 1, package.root,
            scormType=self.scormType, metadataType=self.metadataType) ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir, self.pages)
            if not self.hasForum:
                for idevice in page.node.idevices:
                    if hasattr(idevice, "isForum"):
                        if idevice.forum.lms.lms == "moodle":
                            self.hasForum = True
                            break

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
        modifiedMetaData = manifest.save("imsmanifest.xml")

        # Create lang file
        langFile = open(outputDir + '/common_i18n.js', "w")
        langFile.write(common.getJavaScriptStrings(False))
        langFile.close()

        if self.hasForum:
            manifest.save("discussionforum.xml")

        # Copy the style files to the output dir

        styleFiles = [self.styleDir/'..'/'popup_bg.gif']
        # And with all the files of the style we avoid problems:
        styleFiles += self.styleDir.files("*.*")
        if self.scormType == "commoncartridge":
            for sf in styleFiles[:]:
                if sf.basename() not in manifest.dependencies:
                    styleFiles.remove(sf)
        self.styleDir.copylist(styleFiles, outputDir)

        listCSSFiles=getFilesCSSToMinify('scorm', self.styleDir)
        exportMinFileCSS(listCSSFiles, outputDir)

        # Copy the scripts

        dT = common.getExportDocType()
        if dT == "HTML5":
            #listFiles+=[self.scriptsDir/'exe_html5.js']
            #listOutFiles+=[outputDir/'exe_html5.js']
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(outputDir/'exe_html5.js')

        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                #listFiles+=[self.scriptsDir/'exe_jquery.js']
                #listOutFiles+=[outputDir/'exe_jquery.js']
#.........这里部分代码省略.........
开发者ID:exelearning,项目名称:iteexe,代码行数:101,代码来源:scormexport.py

示例10: Package

class Package(Persistable):
    """
    Package represents the collection of resources the user is editing
    i.e. the "package".
    """

    persistenceVersion = 9
    nonpersistant = ["resourceDir", "filename"]
    # Name is used in filenames and urls (saving and navigating)
    _name = ""
    tempFile = False  # This is set when the package is saved as a temp copy file
    # Title is rendered in exports
    _title = ""
    _author = ""
    _description = ""
    _backgroundImg = ""
    # This is like a constant
    defaultLevelNames = [x_(u"Topic"), x_(u"Section"), x_(u"Unit")]

    def __init__(self, name):
        """
        Initialize 
        """
        log.debug(u"init " + repr(name))
        self._nextIdeviceId = 0
        self._nextNodeId = 0
        # For looking up nodes by ids
        self._nodeIdDict = {}

        self._levelNames = self.defaultLevelNames[:]
        self.name = name
        self._title = u""
        self._backgroundImg = u""
        self.backgroundImgTile = False

        # Empty if never saved/loaded
        self.filename = u""

        self.root = Node(self, None, _(u"Home"))
        self.currentNode = self.root
        self.style = u"default"
        self.isChanged = False
        self.idevices = []
        self.dublinCore = DublinCore()
        self.scolinks = False
        self.license = "None"
        self.footer = ""

        # Temporary directory to hold resources in
        self.resourceDir = TempDirPath()
        self.resources = {}  # Checksum-[_Resource(),..]

    # Property Handlers

    def set_name(self, value):
        self._name = toUnicode(value)

    def set_title(self, value):
        self._title = toUnicode(value)

    def set_author(self, value):
        self._author = toUnicode(value)

    def set_description(self, value):
        self._description = toUnicode(value)

    def get_backgroundImg(self):
        """Get the background image for this package"""
        if self._backgroundImg:
            return "file://" + self._backgroundImg.path
        else:
            return ""

    def set_backgroundImg(self, value):
        """Set the background image for this package"""
        if self._backgroundImg:
            self._backgroundImg.delete()

        if value:
            if value.startswith("file://"):
                value = value[7:]

            imgFile = Path(value)
            self._backgroundImg = Resource(self, Path(imgFile))
        else:
            self._backgroundImg = u""

    def get_level1(self):
        return self.levelName(0)

    def set_level1(self, value):
        if value != "":
            self._levelNames[0] = value
        else:
            self._levelNames[0] = self.defaultLevelNames[0]

    def get_level2(self):
        return self.levelName(1)

    def set_level2(self, value):
#.........这里部分代码省略.........
开发者ID:kohnle-lernmodule,项目名称:exeLearningPlus1_04,代码行数:101,代码来源:package.py

示例11: Exception

            print '"ncftpget" not found. Go: sudo apt-get install ncftp'
        if not ok:
            sys.exit(1)
        os.system("fakeroot debian/rules binary")
    else:
        raise Exception('You need to copy the firefox installation to "exe/webui/firefox"')
packages = (exeDir / "..").glob("*.deb")
if not packages:
    print "No packages found"
    sys.exit(1)
packages.sort()
package = packages[-1]
tmp = None
if "index" in sys.argv:
    print "Creating Index..."
    tmp = TempDirPath()
    pool = tmp / "pool"
    pool.mkdir()
    package.copyfile(pool / package.basename())
    pool.chdir()
    tmp.chdir()
    os.system("dpkg-scanpackages pool /dev/null | gzip -9c > pool/Packages.gz")
if "copy" in sys.argv:
    if "index" in sys.argv:
        print "copying index file to", exeDir
        (pool / "Packages.gz").copy(exeDir)
    pool = exeDir
if server:
    print "connecting to %s..." % server
    from socket import socket, gethostbyname
开发者ID:,项目名称:,代码行数:30,代码来源:

示例12: export

    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        # Copy the style sheet files to the output dir
        # But not nav.css
        styleFiles  = [self.styleDir/'..'/'base.css']
        styleFiles += [self.styleDir/'..'/'popup_bg.gif']
        styleFiles += self.styleDir.files("*.css")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        styleFiles += self.styleDir.files("*.jpg")
        styleFiles += self.styleDir.files("*.gif")
        styleFiles += self.styleDir.files("*.png")
        styleFiles += self.styleDir.files("*.js")
        styleFiles += self.styleDir.files("*.html")
        styleFiles += self.styleDir.files("*.ttf")
        styleFiles += self.styleDir.files("*.eot")
        styleFiles += self.styleDir.files("*.otf")
        styleFiles += self.styleDir.files("*.woff")
        self.styleDir.copylist(styleFiles, outputDir)

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)
            
        # Export the package content
        self.pages = [ IMSPage("index", 1, package.root) ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages)
        manifest.save()
        
        # Copy the scripts
        self.scriptsDir.copylist(('libot_drag.js',
                                  'common.js'), outputDir)
        
        self.schemasDir.copylist(('imscp_v1p1.xsd',
                                  'imsmd_v1p2p2.xsd',
                                  'ims_xml.xsd'), outputDir)

        # copy players for media idevices.                
        hasFlowplayer     = False
        hasMagnifier      = False
        hasXspfplayer     = False
        hasGallery        = False
        isBreak           = False
        
        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if 'magnifier.swf' in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if 'xspf_player.swf' in idevice.systemResources:
                        hasXspfplayer = True
                if not hasGallery:
                    if 'GalleryIdevice' == idevice.klass:
                        hasGallery = True
                        
        if hasFlowplayer:
            videofile = (self.templatesDir/'flowPlayer.swf')
            videofile.copyfile(outputDir/'flowPlayer.swf')
            controlsfile = (self.templatesDir/'flowplayer.controls.swf')
            controlsfile.copyfile(outputDir/'flowplayer.controls.swf')
        if hasMagnifier:
            videofile = (self.templatesDir/'magnifier.swf')
            videofile.copyfile(outputDir/'magnifier.swf')
        if hasXspfplayer:
            videofile = (self.templatesDir/'xspf_player.swf')
            videofile.copyfile(outputDir/'xspf_player.swf')
        if hasGallery:
            imageGalleryCSS = (self.cssDir/'exe_lightbox.css')
            imageGalleryCSS.copyfile(outputDir/'exe_lightbox.css') 
            imageGalleryJS = (self.scriptsDir/'exe_lightbox.js')
            imageGalleryJS.copyfile(outputDir/'exe_lightbox.js') 
            self.imagesDir.copylist(('exeGallery_actions.png', 'exeGallery_loading.gif', 'stock-insert-image.png'), outputDir)

        if package.license == "GNU Free Documentation License":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
        # Zip it up!
        self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
        # Clean up the temporary dir
#.........这里部分代码省略.........
开发者ID:manamani,项目名称:iteexe,代码行数:101,代码来源:imsexport.py

示例13: export

    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)

        # copy the package's resource files, only non existant in outputDir
#        outputDirFiles = outputDir.files()
#        for rfile in package.resourceDir.files():
#            if rfile not in outputDirFiles:
#                rfile.copy(outputDir)

        # copy the package's resource files, only indexed in package.resources
#        for md5 in package.resources.values():
#            for resource in md5:
#                resource.path.copy(outputDir)

        # Export the package content
        self.pages = [ ScormPage("index", 1, package.root,
            scormType=self.scormType, metadataType=self.metadataType) ]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)
            if not self.hasForum:
                for idevice in page.node.idevices:
                    if hasattr(idevice, "isForum"):
                        if idevice.forum.lms.lms == "moodle":
                            self.hasForum = True
                            break

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
        manifest.save("imsmanifest.xml")
        if self.hasForum:
            manifest.save("discussionforum.xml")
        
        # Copy the style sheet files to the output dir
        # But not nav.css
        styleFiles  = [self.styleDir/'..'/'base.css']
        styleFiles += [self.styleDir/'..'/'popup_bg.gif']
        styleFiles += [f for f in self.styleDir.files("*.css")
                if f.basename() <> "nav.css"] 
        styleFiles += self.styleDir.files("*.jpg")
        styleFiles += self.styleDir.files("*.gif")
        styleFiles += self.styleDir.files("*.png")
        styleFiles += self.styleDir.files("*.js")
        styleFiles += self.styleDir.files("*.html")
        styleFiles += self.styleDir.files("*.ttf")
        styleFiles += self.styleDir.files("*.eot")
        styleFiles += self.styleDir.files("*.otf")
        styleFiles += self.styleDir.files("*.woff")
        # FIXME for now, only copy files referenced in Common Cartridge
        # this really should apply to all exports, but without a manifest
        # of the files needed by an included stylesheet it is too restrictive
        if self.scormType == "commoncartridge":
            for sf in styleFiles[:]:
                if sf.basename() not in manifest.dependencies:
                    styleFiles.remove(sf)
        self.styleDir.copylist(styleFiles, outputDir)

        # Copy the scripts
        if self.scormType == "commoncartridge":
            self.scriptsDir.copylist(('libot_drag.js',
                                      'common.js'), outputDir)
        if self.scormType == "scorm2004":
            self.scriptsDir.copylist(('AC_RunActiveContent.js',
                                      'SCORM_API_wrapper.js',
                                      'SCOFunctions.js', 
                                      'libot_drag.js',
                                      'common.js'), outputDir)     
        if self.scormType != "commoncartridge" and self.scormType != "scorm2004":
            self.scriptsDir.copylist(('APIWrapper.js', 
                                      'SCOFunctions.js', 
                                      'libot_drag.js',
                                      'common.js'), outputDir)
        schemasDir = ""
        if self.scormType == "scorm1.2":
            schemasDir = self.schemasDir/"scorm1.2"
            schemasDir.copylist(('imscp_rootv1p1p2.xsd',
                                'imsmd_rootv1p2p1.xsd',
                                'adlcp_rootv1p2.xsd',
                                'ims_xml.xsd'), outputDir)
        elif self.scormType == "scorm2004":
            schemasDir = self.schemasDir/"scorm2004"
            schemasDir.copylist(('adlcp_v1p3.xsd',
                                'adlnav_v1p3.xsd',
                                'adlseq_v1p3.xsd', 
                                'datatypes.dtd', 
                                'imscp_v1p1.xsd',
                                'imsssp_v1p0.xsd',
                                'imsss_v1p0.xsd',
                                'imsss_v1p0auxresource.xsd',
                                'imsss_v1p0control.xsd',
#.........这里部分代码省略.........
开发者ID:manamani,项目名称:iteexe,代码行数:101,代码来源:scormexport.py

示例14: Package

class Package(Persistable):
    """
    Package represents the collection of resources the user is editing
    i.e. the "package".
    """
    persistenceVersion = 7
    nonpersistant      = ['resourceDir', 'filename']
    _name              = '' 
    _title             = '' 
    _author            = ''
    _description       = ''
    _backgroundImg     = ''
    defaultLevelNames  = [x_(u"Topic"), x_(u"Section"), x_(u"Unit")]
    def __init__(self, name):
        """
        Initialize 
        """
        log.debug(u"init " + repr(name))
        self._nextIdeviceId = 0
        self._nextNodeId    = 0
        self._nodeIdDict    = {} 
        self._levelNames    = self.defaultLevelNames[:]
        self.name           = name
        self._title         = u''
        self._backgroundImg = u''
        self.backgroundImgTile = False
        self.filename      = u''
        self.root          = Node(self, None, _(u"Home"))
        self.currentNode   = self.root
        self.style         = u"default"
        self.isChanged     = 0
        self.idevices      = []
        self.dublinCore    = DublinCore()
        self.scolinks      = False
        self.resourceDir = TempDirPath()
    def set_name(self, value):
        self._name = toUnicode(value)
    def set_title(self, value):
        self._title = toUnicode(value)
    def set_author(self, value):
        self._author = toUnicode(value)
    def set_description(self, value):
        self._description = toUnicode(value)
    def get_backgroundImg(self):
        """Get the background image for this package"""
        if self._backgroundImg:
            return "file://" + self._backgroundImg.path
        else:
            return ""
    def set_backgroundImg(self, value):
        """Set the background image for this package"""
        if self._backgroundImg:
            self._backgroundImg.delete()
        if value:
            if value.startswith("file://"):
                value = value[7:]
            imgFile = Path(value)
            self._backgroundImg = Resource(self, Path(imgFile))
        else:
            self._backgroundImg = u''
    def get_level1(self):
        return self.levelName(0)
    def set_level1(self, value):
        if value != '':
            self._levelNames[0] = value 
        else:
            self._levelNames[0] = self.defaultLevelNames[0]
    def get_level2(self):
        return self.levelName(1)
    def set_level2(self, value):
        if value != '':
            self._levelNames[1] = value 
        else:
            self._levelNames[1] = self.defaultLevelNames[1]
    def get_level3(self):
        return self.levelName(2)
    def set_level3(self, value):
        if value != '':
            self._levelNames[2] = value 
        else:
            self._levelNames[2] = self.defaultLevelNames[2]
    name          = property(lambda self:self._name, set_name)
    title         = property(lambda self:self._title, set_title)
    author        = property(lambda self:self._author, set_author)
    description   = property(lambda self:self._description, set_description)
    backgroundImg = property(get_backgroundImg, set_backgroundImg)
    level1 = property(get_level1, set_level1)
    level2 = property(get_level2, set_level2)
    level3 = property(get_level3, set_level3)
    def findNode(self, nodeId):
        """
        Finds a node from its nodeId
        (nodeId can be a string or a list/tuple)
        """
        log.debug(u"findNode" + repr(nodeId))
        node = self._nodeIdDict.get(nodeId)
        if node and node.package is self:
            return node
        else: 
            return None
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例15: export

    def export(self, package):
        """ 
        Export SCORM package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        self.metadataType = package.exportMetadataType

        # Copy the style sheet files to the output dir
        # But not nav.css
        styleFiles = [self.styleDir / ".." / "base.css"]
        styleFiles += [self.styleDir / ".." / "popup_bg.gif"]
        styleFiles += self.styleDir.files("*.css")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        styleFiles += self.styleDir.files("*.jpg")
        styleFiles += self.styleDir.files("*.gif")
        styleFiles += self.styleDir.files("*.png")
        styleFiles += self.styleDir.files("*.js")
        styleFiles += self.styleDir.files("*.html")
        styleFiles += self.styleDir.files("*.ttf")
        styleFiles += self.styleDir.files("*.eot")
        styleFiles += self.styleDir.files("*.otf")
        styleFiles += self.styleDir.files("*.woff")
        self.styleDir.copylist(styleFiles, outputDir)

        # copy the package's resource files
        package.resourceDir.copyfiles(outputDir)

        # Export the package content
        self.pages = [IMSPage("index", 1, package.root, metadataType=self.metadataType)]

        self.generatePages(package.root, 2)
        uniquifyNames(self.pages)

        for page in self.pages:
            page.save(outputDir)

        # Create the manifest file
        manifest = Manifest(self.config, outputDir, package, self.pages, self.metadataType)
        manifest.save("imsmanifest.xml")

        # Copy the scripts

        # jQuery
        my_style = G.application.config.styleStore.getStyle(page.node.package.style)
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = self.scriptsDir / "exe_jquery.js"
                jsFile.copyfile(outputDir / "exe_jquery.js")
        else:
            jsFile = self.scriptsDir / "exe_jquery.js"
            jsFile.copyfile(outputDir / "exe_jquery.js")

        jsFile = self.scriptsDir / "common.js"
        jsFile.copyfile(outputDir / "common.js")
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = self.scriptsDir / "exe_html5.js"
            jsFile.copyfile(outputDir / "exe_html5.js")

        self.schemasDir.copylist(
            ("imscp_v1p1.xsd", "imsmd_v1p2p2.xsd", "lom.xsd", "lomCustom.xsd", "ims_xml.xsd"), outputDir
        )

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasMediaelement = False

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (
                    hasFlowplayer
                    and hasMagnifier
                    and hasXspfplayer
                    and hasGallery
                    and hasWikipedia
                    and hasInstructions
                    and hasMediaelement
                ):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if "flowPlayer.swf" in idevice.systemResources:
                        hasFlowplayer = True
                if not hasMagnifier:
                    if "mojomagnify.js" in idevice.systemResources:
                        hasMagnifier = True
                if not hasXspfplayer:
                    if "xspf_player.swf" in idevice.systemResources:
                        hasXspfplayer = True
#.........这里部分代码省略.........
开发者ID:RichDijk,项目名称:eXe,代码行数:101,代码来源:imsexport.py


注:本文中的exe.engine.path.TempDirPath类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。