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


Python Path.mkdir方法代码示例

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


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

示例1: exportWebSite

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
 def exportWebSite(self, client, filename, webDir, stylesDir):
     """
     Export 'client' to a web site,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     """
     imagesDir    = webDir.joinpath('images')
     scriptsDir   = webDir.joinpath('scripts')
     templatesDir = webDir.joinpath('templates')
     filename = Path(filename)
     if filename.basename() != self.package.name:
         filename /= self.package.name
     if not filename.exists():
         filename.makedirs()
     elif not filename.isdir():
         client.alert(_(u'Filename %s is a file, cannot replace it') % 
                      filename)
         log.error("Couldn't export web page: "+
                   "Filename %s is a file, cannot replace it" % filename)
         return
     else:
         filename.rmtree()
         filename.mkdir()
     websiteExport = WebsiteExport(stylesDir, filename, 
                                   imagesDir, scriptsDir, templatesDir)
     websiteExport.export(self.package)
     self._startFile(filename)
开发者ID:,项目名称:,代码行数:29,代码来源:

示例2: exportSinglePage

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
 def exportSinglePage(self, client, filename, webDir, stylesDir):
     """
     Export 'client' to a single web page,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     """
     imagesDir    = webDir.joinpath('images')
     scriptsDir   = webDir.joinpath('scripts')
     templatesDir = webDir.joinpath('templates')
     filename = Path(filename)
     if filename.basename() != self.package.name:
         filename /= self.package.name
     if not filename.exists():
         filename.makedirs()
     elif not filename.isdir():
         client.alert(_(u'Filename %s is a file, cannot replace it') % 
                      filename)
         log.error("Couldn't export web page: "+
                   "Filename %s is a file, cannot replace it" % filename)
         return
     else:
         try:
             filename.rmtree()
             filename.mkdir()
         except Exception, e:
             client.alert(_('There was an error in the export:\n%s') % str(e))
             return
开发者ID:,项目名称:,代码行数:29,代码来源:

示例3: _setupConfigFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
 def _setupConfigFile(self, configParser):
     """
     Override this to setup any customised config
     settings
     """
     # Set up the system section
     system = configParser.addSection('system')
     system.exePath = 'exe/exe'
     system.exeDir = 'exe'
     system.webDir = 'exe/webui'
     system.localeDir = 'exe/locale'
     system.configDir = 'tmp'
     system.port = 8081
     # Make a temporary dir where we can save packages and exports etc
     tmpDir = Path('tmp')
     if not tmpDir.exists():
         tmpDir.mkdir()
     dataDir = tmpDir / 'data'
     if not dataDir.exists():
         dataDir.mkdir()
     system.dataDir = dataDir
     system.browserPath = 'not really used in tests so far'
     # Setup the logging section
     logging = configParser.addSection('logging')
     logging.root = 'DEBUG'
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:27,代码来源:utils.py

示例4: _setupConfigFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
 def _setupConfigFile(self, configParser):
     """
     Setup our own config file
     """
     utils.SuperTestCase._setupConfigFile(self, configParser)
     tmp = Path('tmp')
     if not tmp.exists():
         tmp.mkdir()
     logfn = tmp/'exe.log'
     if logfn.exists():
         try:
             logfn.remove()
         except OSError:
             pass
     configParser.system.configDir = tmp
     configParser.logging.root = 'ERROR'
     configParser.logging.foo = 'DEBUG'
     configParser.logging.foo = 'DEBUG'
开发者ID:,项目名称:,代码行数:20,代码来源:

示例5: SinglePageExport

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
class SinglePageExport(object):
    """
    SinglePageExport will export a package as a website of HTML pages
    """
    def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, templatesDir):
        """
        'stylesDir' is the directory where we can copy the stylesheets from
        'outputDir' is the directory that will be [over]written
        with the website
        """
        self.html         = ""
        self.style        = None
        self.name         = None
        self.stylesDir    = Path(stylesDir)
        self.outputDir    = Path(outputDir)
        self.imagesDir    = Path(imagesDir)
        self.scriptsDir   = Path(scriptsDir)
        self.templatesDir = Path(templatesDir)
	self.page         = None

        # Create the output dir if it doesn't already exist
        if not self.outputDir.exists(): 
            self.outputDir.mkdir()


    def export(self, package, for_print=0):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        self.style = package.style       
	
	self.page = SinglePage("index", 1, package.root)

        self.page.save(self.outputDir/"index.html", for_print)
	
	self.copyFiles(package)


    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        # Copy the style sheet files to the output dir
        # But not nav.css
        styleFiles  = [self.stylesDir/'..'/'base.css']
	styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
        styleFiles += self.stylesDir.files("*.css")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        styleFiles += self.stylesDir.files("*.jpg")
        styleFiles += self.stylesDir.files("*.gif")
        styleFiles += self.stylesDir.files("*.png")
        styleFiles += self.stylesDir.files("*.js")
        styleFiles += self.stylesDir.files("*.html")
        self.stylesDir.copylist(styleFiles, self.outputDir)

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

        # copy script files.
        self.scriptsDir.copylist(('libot_drag.js', 'common.js'), 
                                     self.outputDir)
	
	# copy players for media idevices.                
        hasFlowplayer     = False
        hasMagnifier      = False
        hasXspfplayer     = False

	for idevice in self.page.node.idevices:
	    if (hasFlowplayer and hasMagnifier and hasXspfplayer):
		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 hasFlowplayer:
            videofile = (self.templatesDir/'flowPlayer.swf')
            videofile.copyfile(self.outputDir/'flowPlayer.swf')
        if hasMagnifier:
            videofile = (self.templatesDir/'magnifier.swf')
            videofile.copyfile(self.outputDir/'magnifier.swf')
        if hasXspfplayer:
            videofile = (self.templatesDir/'xspf_player.swf')
            videofile.copyfile(self.outputDir/'xspf_player.swf')


        if package.license == "GNU Free Documentation License":
            # include a copy of the GNU Free Documentation Licence
            (self.templatesDir/'fdl.html').copyfile(self.outputDir/'fdl.html')
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:98,代码来源:singlepageexport.py

示例6: SinglePageExport

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
class SinglePageExport(object):
    """
    SinglePageExport will export a package as a website of HTML pages
    """
    def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, cssDir, templatesDir):
        """
        'stylesDir' is the directory where we can copy the stylesheets from
        'outputDir' is the directory that will be [over]written
        with the website
        """
        self.html         = ""
        self.style        = None
        self.name         = None
        self.stylesDir    = Path(stylesDir)
        self.outputDir    = Path(outputDir)
        self.imagesDir    = Path(imagesDir)
        self.scriptsDir   = Path(scriptsDir)
        self.cssDir       = Path(cssDir)
        self.templatesDir = Path(templatesDir)
	self.page         = None

        # Create the output dir if it doesn't already exist
        if not self.outputDir.exists(): 
            self.outputDir.mkdir()


    def export(self, package, for_print=0):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        self.style = package.style

        self.page = SinglePage("index", 1, package.root)

        self.page.save(self.outputDir/"index.html", for_print)
        if hasattr(package, 'exportSource') and package.exportSource and not for_print:
            (G.application.config.webDir/'templates'/'content.xsd').copyfile(self.outputDir/'content.xsd')
            (self.outputDir/'content.data').write_bytes(encodeObject(package))
            (self.outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))

        self.copyFiles(package)


    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        # Copy the style sheet files to the output dir
        # But not nav.css
        if os.path.isdir(self.stylesDir):
            # Copy the style sheet files to the output dir
            styleFiles  = [self.stylesDir/'..'/'base.css']
            styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.css")
            if "nav.css" in styleFiles:
                styleFiles.remove("nav.css")
            styleFiles += self.stylesDir.files("*.jpg")
            styleFiles += self.stylesDir.files("*.gif")
            styleFiles += self.stylesDir.files("*.png")
            styleFiles += self.stylesDir.files("*.js")
            styleFiles += self.stylesDir.files("*.html")
            styleFiles += self.stylesDir.files("*.ico")
            styleFiles += self.stylesDir.files("*.ttf")
            styleFiles += self.stylesDir.files("*.eot")
            styleFiles += self.stylesDir.files("*.otf")
            styleFiles += self.stylesDir.files("*.woff")
            self.stylesDir.copylist(styleFiles, self.outputDir)
            
        # copy the package's resource files
        package.resourceDir.copyfiles(self.outputDir)

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)
        
        # jQuery
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(self.outputDir/'exe_jquery.js')
        else:
            jsFile = (self.scriptsDir/'exe_jquery.js')
            jsFile.copyfile(self.outputDir/'exe_jquery.js')
            
        jsFile = (self.scriptsDir/'common.js')
        jsFile.copyfile(self.outputDir/'common.js')
        jsFile = (self.scriptsDir/'lernmodule_net.js')
        jsFile.copyfile(self.outputDir/'lernmodule_net.js')
        dT = common.getExportDocType()
        if dT == "HTML5":
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(self.outputDir/'exe_html5.js')
            
        # Incluide eXe's icon if the Style doesn't have one
        themePath = Path(G.application.config.stylesDir/package.style)
        themeFavicon = themePath.joinpath("favicon.ico")
        if not themeFavicon.exists():
            faviconFile = (self.imagesDir/'favicon.ico')
            faviconFile.copyfile(self.outputDir/'favicon.ico')

#.........这里部分代码省略.........
开发者ID:kohnle-lernmodule,项目名称:exe201based,代码行数:103,代码来源:singlepageexport.py

示例7: load

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
    def load(filename, newLoad=True, destinationPackage=None, fromxml=None):
        """
        Load package from disk, returns a package.
        """
        if not zipfile.is_zipfile(filename):
            return None

        zippedFile = zipfile.ZipFile(filename, "r")

        xml = None
        
        try:
            xml = zippedFile.read(u"contentv2.xml")
        except:
            pass
        
        if not xml:
            try:
                # Get the jellied package data
                toDecode   = zippedFile.read(u"content.data")
            except KeyError:
                log.info("no content.data, trying Common Cartridge/Content Package")
                newPackage = loadCC(zippedFile, filename)
                newPackage.tempFile = False
                newPackage.isChanged = False
                newPackage.filename = Path(filename)
    
                return newPackage
            
        # Need to add a TempDirPath because it is a nonpersistant member
        resourceDir = TempDirPath()

        # Extract resource files from package to temporary directory
        for fn in zippedFile.namelist():
            if unicode(fn, 'utf8') not in [u"content.data", u"content.xml", u"contentv2.xml", u"content.xsd" ]:
                #JR: Hacemos las comprobaciones necesarias por si hay directorios
                if ("/" in fn):
                    dir = fn[:fn.index("/")]
                    Dir = Path(resourceDir/dir)
                    if not Dir.exists():
                        Dir.mkdir()
                Fn = Path(resourceDir/fn)
                if not Fn.isdir():
                    outFile = open(resourceDir/fn, "wb")
                    outFile.write(zippedFile.read(fn))
                    outFile.flush()
                    outFile.close()

        try:
            validxml = False
            if fromxml:
                newPackage, validxml = decodeObjectFromXML(fromxml)
            elif xml:
                xmlinfo = zippedFile.getinfo(u"contentv2.xml")
                datainfo = zippedFile.getinfo(u"content.data")
                if xmlinfo.date_time >= datainfo.date_time:
                    newPackage, validxml = decodeObjectFromXML(xml)
            if not validxml:
                toDecode   = zippedFile.read(u"content.data")
                newPackage = decodeObjectRaw(toDecode)
            G.application.afterUpgradeHandlers = []
            newPackage.resourceDir = resourceDir
            G.application.afterUpgradeZombies2Delete = []
            if not validxml and (xml or fromxml or "content.xml" in zippedFile.namelist()):
                for key, res in newPackage.resources.items():
                    if len(res) < 1:
                        newPackage.resources.pop(key)
                    else:
                        res[0].testForAndDeleteZombieResources()

            if newLoad: 
                # provide newPackage to doUpgrade's versionUpgrade() to
                # correct old corrupt extracted packages by setting the
                # any corrupt package references to the new package:

                log.debug("load() about to doUpgrade newPackage \"" 
                        + newPackage._name + "\" " + repr(newPackage) )
                if hasattr(newPackage, 'resourceDir'):
                    log.debug("newPackage resourceDir = "
                            + newPackage.resourceDir)
                else:
                    # even though it was just set above? should not get here:
                    log.error("newPackage resourceDir has NO resourceDir!")

                doUpgrade(newPackage)

                # after doUpgrade, compare the largest found field ID:
                if G.application.maxFieldId >= Field.nextId:
                    Field.nextId = G.application.maxFieldId + 1

            else: 
                # and when merging, automatically set package references to
                # the destinationPackage, into which this is being merged:

                log.debug("load() about to merge doUpgrade newPackage \"" 
                        + newPackage._name + "\" " + repr(newPackage)
                        + " INTO destinationPackage \"" 
                        + destinationPackage._name + "\" " 
                        + repr(destinationPackage))
                
#.........这里部分代码省略.........
开发者ID:manamani,项目名称:iteexe,代码行数:103,代码来源:package.py

示例8: export

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
    def export(self, package):
        """
        Export epub 3 package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        '''
        fileDir = outputDir/"META-INF"
        fileDir.mkdir()
        fileDir = outputDir/"Content"
        fileDir.mkdir()
        '''

        metainfPages = Path(outputDir.abspath() + '/META-INF')
        # metainfPages = outputDir/'META-INF'
        metainfPages.mkdir()
        contentPages = Path(outputDir.abspath() + '/EPUB')
        # contentPages = outputDir/'Content'
        contentPages.mkdir()
        # print contentPages.abspath()
        # print outputDir.abspath()

        # Export the package content
        self.pages = [Epub3Cover("cover", 1, package.root)]

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

        cover = None
        for page in self.pages:
            page.save(contentPages, self.pages)
            if hasattr(page, 'cover'):
                cover = page.cover

        # Create mimetype file
        mimetypeFile = open(outputDir.abspath() + '/mimetype', "w")
        mimetypeFile.write('application/epub+zip')
        mimetypeFile.close()

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

        # Copy the style files to the output dir
        # But not nav.css
        styleFiles = [self.styleDir /'..'/ 'popup_bg.gif']
        styleFiles += [f for f in self.styleDir.files("*.*") if f.basename() not in ['nav.css']]

        # 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

        # Add fallback document for possible image links
        if Path(self.styleDir/'fallback.xhtml').exists():
            styleFiles += [self.styleDir /'fallback.xhtml']
        else:
            styleFiles += [self.styleDir/'..'/'fallback.xhtml']

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

            if ("/" in fn):
                Dir = Path(contentPages/fn[:fn.rindex("/")])
                if not Dir.exists():
                    Dir.makedirs()

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

        self.styleDir.copylist(styleFiles, contentPages)

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasFX = False
        hasSH = False
        hasGames = False
        hasElpLink = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasTooltips = False
        hasABCMusic = False

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
                if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery and hasFX and hasSH and hasGames and hasElpLink and hasWikipedia and hasInstructions and hasTooltips and hasABCMusic):
                    isBreak = True
                    break
                if not hasFlowplayer:
                    if 'flowPlayer.swf' in idevice.systemResources:
                        hasFlowplayer = True
#.........这里部分代码省略.........
开发者ID:exelearning,项目名称:iteexe,代码行数:103,代码来源:epub3export.py

示例9: SinglePageExport

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
class SinglePageExport(object):
    """
    SinglePageExport will export a package as a website of HTML pages
    """
    def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, templatesDir):
        """
        'stylesDir' is the directory where we can copy the stylesheets from
        'outputDir' is the directory that will be [over]written
        with the website
        """
        self.html         = ""
        self.style        = None
        self.name         = None
        self.stylesDir    = Path(stylesDir)
        self.outputDir    = Path(outputDir)
        self.imagesDir    = Path(imagesDir)
        self.scriptsDir   = Path(scriptsDir)
        self.templatesDir = Path(templatesDir)
        if not self.outputDir.exists(): 
            self.outputDir.mkdir()
    def export(self, package):
        """ 
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        self.style = package.style
        self.copyFiles(package)
        self.html  = self.renderHeader(package.name)
        self.html += u"<body>\n"
        self.html += u"<div id=\"content\">\n"
        self.html += u"<div id=\"header\">\n"
        self.html += escape(package.title)
        self.html += u"</div>\n"
        self.html += u"<div id=\"main\">\n"
        self.renderNode(package.root)
        self.html += u"</div>\n"
        self.html += u"</div>\n"
        self.html += u"</body></html>\n"
        self.save(self.outputDir/"index.html")
    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        styleFiles  = [self.stylesDir/'..'/'base.css']
	styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
        styleFiles += self.stylesDir.files("*.css")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        styleFiles += self.stylesDir.files("*.jpg")
        styleFiles += self.stylesDir.files("*.gif")
        styleFiles += self.stylesDir.files("*.png")
        styleFiles += self.stylesDir.files("*.js")
        styleFiles += self.stylesDir.files("*.html")
        self.stylesDir.copylist(styleFiles, self.outputDir)
        package.resourceDir.copyfiles(self.outputDir)
        self.scriptsDir.copylist(('libot_drag.js', 'common.js'), 
                                     self.outputDir)
        self.templatesDir.copylist(('videoContainer.swf', 'magnifier.swf',
                                    'xspf_player.swf'),self.outputDir)
        (self.templatesDir/'fdl.html').copyfile(self.outputDir/'fdl.html')
    def renderHeader(self, name):
        """
        Returns an XHTML string for the header of this page.
        """
        html  = u"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
        html += u'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 '
        html += u'Transitional//EN" '
        html += u'"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n'
        html += u"<html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
        html += u"<head>\n"
        html += u"<style type=\"text/css\">\n"
        html += u"@import url(base.css);\n"
        html += u"@import url(content.css);\n"
        html += u"</style>"
        html += u"<title>"
        html += name
        html += "</title>\n"
        html += u"<meta http-equiv=\"Content-Type\" content=\"text/html; "
        html += u" charset=utf-8\" />\n";
        html += u'<script type="text/javascript" src="common.js"></script>\n'
        html += u"</head>\n"
        return html
    def renderNode(self, node):
        """
        Returns an XHTML string for this node and recurse for the children
        """
        self.html += '<div id=\"nodeDecoration\">'
        self.html += '<p id=\"nodeTitle\">'
        self.html += escape(node.titleLong)
        self.html += '</p></div>\n'
        for idevice in node.idevices:
            block = g_blockFactory.createBlock(None, idevice)
            if not block:
                log.critical("Unable to render iDevice.")
                raise Error("Unable to render iDevice.")
            if hasattr(idevice, "isQuiz"):
                self.html += block.renderJavascriptForWeb()
            self.html += block.renderView(self.style)
        for child in node.children:
            self.renderNode(child)
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例10: SinglePageExport

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
class SinglePageExport(object):
    """
    SinglePageExport will export a package as a website of HTML pages
    """
    def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, cssDir, templatesDir):
        """
        'stylesDir' is the directory where we can copy the stylesheets from
        'outputDir' is the directory that will be [over]written
        with the website
        """
        self.html         = ""
        self.style        = None
        self.name         = None
        self.stylesDir    = Path(stylesDir)
        self.outputDir    = Path(outputDir)
        self.imagesDir    = Path(imagesDir)
        self.scriptsDir   = Path(scriptsDir)
        self.cssDir       = Path(cssDir)
        self.templatesDir = Path(templatesDir)
	self.page         = None

        # Create the output dir if it doesn't already exist
        if not self.outputDir.exists():
            self.outputDir.mkdir()


    def export(self, package, for_print=0):
        """
        Export web site
        Cleans up the previous packages pages and performs the export
        """
        self.style = package.style

        self.page = SinglePage("index", 1, package.root)
        ext = 'html'
        if G.application.config.cutFileName == "1":
            ext = 'htm'

        self.page.save(self.outputDir/"index" + '.' + ext, for_print)
        if hasattr(package, 'exportSource') and package.exportSource and not for_print:
            (G.application.config.webDir/'templates'/'content.xsd').copyfile(self.outputDir/'content.xsd')
            (self.outputDir/'content.data').write_bytes(encodeObject(package))
            (self.outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))

        self.copyFiles(package)


    def copyFiles(self, package):
        """
        Copy all the files used by the website.
        """
        # Copy the style files to the output dir
        # But not nav.css
        if os.path.isdir(self.stylesDir):
            styleFiles = [self.stylesDir/'..'/'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.*")
            if "nav.css" in styleFiles:
                styleFiles.remove("nav.css")
            self.stylesDir.copylist(styleFiles, self.outputDir)

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

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

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

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

        listCSSFiles=getFilesCSSToMinify('singlepage', self.stylesDir)
        exportMinFileCSS(listCSSFiles, self.outputDir)

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)

        # jQuery
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(self.outputDir/'exe_jquery.js')
        else:
            jsFile = (self.scriptsDir/'exe_jquery.js')
            jsFile.copyfile(self.outputDir/'exe_jquery.js')

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

        # Minify common.js file
        listFiles=getFilesJSToMinify('singlepage', self.scriptsDir)
        exportMinFileJS(listFiles, self.outputDir)

        # Create lang file
        langFile = open(self.outputDir + '/common_i18n.js', "w")
#.........这里部分代码省略.........
开发者ID:exelearning,项目名称:iteexe,代码行数:103,代码来源:singlepageexport.py

示例11: __init__

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]

#.........这里部分代码省略.........
            if system.has_option('greDir'):
                del system.greDir
    def loadSettings(self):
        """
        Loads the settings from the exe.conf file.
        Overrides the defaults set in __init__
        """
        def defVal(dummy, option):
            """If something is not in the config file, just use the default in
            'self'"""
            return getattr(self, option)
        self.configParser.defaultValue = defVal
        self.upgradeFile()
        if self.configParser.has_section('system'):
            system = self.configParser.system
            self.webDir         = Path(system.webDir)
            self.xulDir         = Path(system.xulDir)
            self.localeDir      = Path(system.localeDir)
            self.port           = int(system.port)
            self.browserPath    = Path(system.browserPath)
            self.dataDir        = Path(system.dataDir)
            self.configDir      = Path(system.configDir)
            self.assumeMediaPlugins = False;
            if self.configParser.has_option('system', \
                    'assumeMediaPlugins'):
               value = system.assumeMediaPlugins.strip().lower()
               if value == "1" or value == "yes" or value == "true" or \
                   value == "on":
                       self.assumeMediaPlugins = True;
        if not self.dataDir.isdir():
            self.dataDir = tempfile.gettempdir()
        self.webDir = self.webDir.expand().abspath()
        if not self.configDir.exists():
            self.configDir.mkdir()
        self.recentProjects = []
        if self.configParser.has_section('recent_projects'):
            recentProjectsSection = self.configParser.recent_projects
            for key, path in recentProjectsSection.items():
                self.recentProjects.append(path)
        self.hiddeniDevices = []
        if self.configParser.has_section('idevices'):
            idevicesSection = self.configParser.idevices
            for key,value in idevicesSection.items():
                value = value.strip().lower()
                if value == "0" or value == "no" or value == "false" or \
                        value == "off":
                    self.hiddeniDevices.append(key.lower())
        if self.configParser.has_section('deprecated'):
            deprecatedSection = self.configParser.deprecated
            for key,value in deprecatedSection.items():
                value = value.strip().lower()
                if value == "1" or value == "yes" or value == "true" or \
                        value == "on":
                    if key.lower() in self.deprecatediDevices:
                        self.deprecatediDevices.remove(key.lower())
        if self.configParser.has_section('user'):
            if self.configParser.user.has_option('locale'):
                self.locale = self.configParser.user.locale
                return
        self.locale = chooseDefaultLocale(self.localeDir)
    def onWrite(self, configParser):
        """
        Called just before the config file is written.
        We use it to fill out any settings that are stored here and 
        not in the config parser itself
        """
开发者ID:,项目名称:,代码行数:70,代码来源:

示例12: __init__

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]

#.........这里部分代码省略.........
        def defVal(dummy, option):
            """If something is not in the config file, just use the default in
            'self'"""
            return getattr(self, option)
        self.configParser.defaultValue = defVal
        self.upgradeFile()
        # System Section
        if self.configParser.has_section('system'):
            system = self.configParser.system
            self.webDir         = Path(system.webDir)
            self.xulDir         = Path(system.xulDir)
            self.localeDir      = Path(system.localeDir)
            self.port           = int(system.port)
            self.browserPath    = Path(system.browserPath)
            self.dataDir        = Path(system.dataDir)
            self.configDir      = Path(system.configDir)
            
            self.assumeMediaPlugins = False;
            if self.configParser.has_option('system', \
                    'assumeMediaPlugins'):
               value = system.assumeMediaPlugins.strip().lower()
               if value == "1" or value == "yes" or value == "true" or \
                   value == "on":
                       self.assumeMediaPlugins = True;

        # If the dataDir points to some other dir, fix it
        if not self.dataDir.isdir():
            self.dataDir = tempfile.gettempdir()
        # make the webDir absolute, to hide path joins of relative paths
        self.webDir = self.webDir.expand().abspath()
        # If the configDir doesn't exist (as it may be a default setting with a
        # new installation) create it
        if not self.configDir.exists():
            self.configDir.mkdir()
                
        # Get the list of recently opened projects
        self.recentProjects = []
        if self.configParser.has_section('recent_projects'):
            recentProjectsSection = self.configParser.recent_projects
            for key, path in recentProjectsSection.items():
                self.recentProjects.append(path)
                
        # Load the list of "hidden" iDevices
        self.hiddeniDevices = []
        if self.configParser.has_section('idevices'):
            idevicesSection = self.configParser.idevices
            for key,value in idevicesSection.items():
                # emulate standard library's getboolean()
                value = value.strip().lower()
                if value == "0" or value == "no" or value == "false" or \
                        value == "off":
                    self.hiddeniDevices.append(key.lower())

        #self.deprecatediDevices = [ "flash with text", "flash movie", ...]
        # and UN-Load from the list of "deprecated" iDevices
        if self.configParser.has_section('deprecated'):
            deprecatedSection = self.configParser.deprecated
            for key,value in deprecatedSection.items():
                # emulate standard library's getboolean()
                value = value.strip().lower()
                if value == "1" or value == "yes" or value == "true" or \
                        value == "on":
                    if key.lower() in self.deprecatediDevices:
                        self.deprecatediDevices.remove(key.lower())

        # Load the "user" section
开发者ID:KatiaBorges,项目名称:exeLearning,代码行数:70,代码来源:config.py

示例13: export_to_dir

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
    def export_to_dir(self, package, outputDir):
        metainfPages = Path(outputDir.abspath() + '/META-INF')
        metainfPages.mkdir()
        contentPages = Path(outputDir.abspath() + '/EPUB')
        contentPages.mkdir()
        
        
        mimetypeFile = open(outputDir.abspath() + '/mimetype', "w")
        mimetypeFile.write('application/epub+zip')
        mimetypeFile.close()
        
        Epub3Export.current_package_name = package.name
        Epub3Export.current_xapi_prefix = \
            EXETinCan.get_tincan_prefix_for_pkg(package)
        Epub3Export.current_package_title = \
            package.title 
        
        #Command line option to override language for export
        if self.langOverride != None:
            package.dublinCore.language = self.langOverride
        
        #track the number of working idevices on a page
        #if 0 do not put page in TOC
        numDevicesByPage = {}
        
        #track idevices that dont really  export
        nonDevices = []
        
        #
        #This is passed from the command line export
        #
        if self.forceMediaOnly == True:
            package.mxmlforcemediaonly = "true"
        
        mediaConverter = ExportMediaConverter()
        

        
        mediaConverter.setCurrentPackage(package)
        ExportMediaConverter.autoMediaOnly = package.mxmlforcemediaonly
        if 'FORCEMEDIAONLY' in os.environ:
            ExportMediaConverter.autoMediaOnly = True
        
        ExportMediaConverter.setWorkingDir(contentPages)

        indexPageXML = XMLPage("index", 1, package.root)
        self.pages = [ indexPageXML ]
        
        
        
        self.pkgNodeToPageDict = self.generatePagesXML(package.root, 1)
        self.pkgNodeToPageDict[package.root] = indexPageXML
        
        uniquifyNames(self.pages, suffix = ".xhtml")
        
        self.generateJQueryMobileTOC(package.root, contentPages)
        
        self.copyFilesXML(package, contentPages)
        
    
        prevPage = None
        thisPage = self.pages[0]
        

        for nextPage in self.pages[1:]:
            pageDevCount = thisPage.save(contentPages, prevPage, \
                                         nextPage, self.pages, nonDevices)
            numDevicesByPage[thisPage.name] = pageDevCount
            prevPage = thisPage
            thisPage = nextPage
             
        pageDevCount = thisPage.save(contentPages, prevPage, None, self.pages, nonDevices)
        numDevicesByPage[thisPage.name] = pageDevCount
        
        self._writeTOCXML(contentPages, numDevicesByPage, nonDevices, package)
        
        #save the tincan.xml file
        self.write_tincan_xml(outputDir, package)
        
        #now go through and make the HTML output
        common.setExportDocType("HTML5")
        
        self.pages = [ Epub3Cover("cover", 1, package.root) ]
        self.generatePages(package.root, 2)
        uniquifyNames(self.pages, suffix=".xhtml")
        
        cover = None
        for page in self.pages:
            page.save(contentPages, ustadmobile_mode = True)
            if hasattr(page, 'cover'):
                cover = page.cover
                
        # Create the nav.xhtml file
        container = NavEpub3(self.pages, contentPages)
        container.save()

        # Create the publication file
        publication = self.make_publication_epub3(contentPages, package, cover)
        publication.save("package.opf")

#.........这里部分代码省略.........
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:103,代码来源:xmlexport.py

示例14: export

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]
    def export(self, package):
        """
        Export epub 3 package
        """
        # First do the export to a temporary directory
        outputDir = TempDirPath()

        '''
        fileDir = outputDir/"META-INF"
        fileDir.mkdir()
        fileDir = outputDir/"Content"
        fileDir.mkdir()
        '''

        metainfPages = Path(outputDir.abspath() + '/META-INF')
        # metainfPages = outputDir/'META-INF'
        metainfPages.mkdir()
        contentPages = Path(outputDir.abspath() + '/EPUB')
        quizContentPages = Path(outputDir.abspath() + '/EPUB/tools/quiz')
        quizImagesPages = Path(quizContentPages.abspath() + '/images')
        quizScriptsPages = Path(quizContentPages.abspath() + '/scripts')
        quizVideoPages = Path(quizContentPages.abspath() + '/video')
        quizCssPages = Path(quizContentPages.abspath() + '/css')
        quizFilesPages = Path(quizContentPages.abspath() + '/css')
        # contentPages = outputDir/'Content'
        contentPages.mkdir()
        quizContentPages.makedirs()
        quizImagesPages.mkdir()
        quizScriptsPages.mkdir()
        quizVideoPages.mkdir()
        quizCssPages.mkdir()
        quizFilesPages.mkdir()
        # print contentPages.abspath()
        # print outputDir.abspath()

        # Export the package content
        self.pages = [Epub3Cover("cover", 1, package.root)]

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

        cover = None
        for page in self.pages:
            page.save(contentPages)
            if hasattr(page, 'cover'):
                cover = page.cover

        # Create mimetype file
        mimetypeFile = open(outputDir.abspath() + '/mimetype', "w")
        mimetypeFile.write('application/epub+zip')
        mimetypeFile.close()

        # Copy the style sheet files to the output dir
        # But not nav.css
        cssStyleFiles = [self.styleDir / '..' / 'base.css']
        cssStyleFiles += [f for f in self.styleDir.files("*.css") if f.basename() != "nav.css"]

        imgStyleFiles = [self.styleDir / '..' / 'popup_bg.gif']
        imgStyleFiles += self.styleDir.files("*.jpg")
        imgStyleFiles += self.styleDir.files("*.gif")
        imgStyleFiles += self.styleDir.files("*.png")

        scriptStyleFiles = self.styleDir.files("*.js")

        filesStyleFiles = self.styleDir.files("*.html")
        filesStyleFiles += self.styleDir.files("*.ttf")
        filesStyleFiles += self.styleDir.files("*.eot")
        filesStyleFiles += self.styleDir.files("*.otf")
        filesStyleFiles += 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

        package.resourceDir.copyfiles(contentPages)

        self.styleDir.copylist(cssStyleFiles, quizCssPages)
        self.styleDir.copylist(imgStyleFiles, quizImagesPages)
        self.styleDir.copylist(scriptStyleFiles, quizScriptsPages)
        self.styleDir.copylist(filesStyleFiles, quizFilesPages)


        self.scriptsDir.copylist(('common.js',), quizScriptsPages)

        # copy players for media idevices.
        hasFlowplayer = False
        hasMagnifier = False
        hasXspfplayer = False
        hasGallery = False
        hasFX = False
        hasSH = False
        hasGames = False
        hasWikipedia = False
        isBreak = False
        hasInstructions = False
        hasTooltips = False

        for page in self.pages:
            if isBreak:
                break
            for idevice in page.node.idevices:
#.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:103,代码来源:

示例15: Config

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import mkdir [as 别名]

#.........这里部分代码省略.........
        if self.configParser.has_section('system'):
            system = self.configParser.system

            
            self.port           = int(system.port)
            self.browser        = None if system.browser == u"None" else system.browser
            
            
            if not G.application.portable:
                self.dataDir        = Path(system.dataDir)
                self.configDir      = Path(system.configDir)
                self.webDir         = Path(system.webDir)
                self.stylesDir      = Path(self.configDir)/'style'
                self.jsDir          = Path(system.jsDir)
            else:
                self.stylesDir      = Path(self.webDir/'style').abspath()
            
            self.assumeMediaPlugins = False;
            if self.configParser.has_option('system', \
                    'assumeMediaPlugins'):
               value = system.assumeMediaPlugins.strip().lower()
               if value == "1" or value == "yes" or value == "true" or \
                   value == "on":
                       self.assumeMediaPlugins = True;

        # If the dataDir points to some other dir, fix it
        if not self.dataDir.isdir():
            self.dataDir = tempfile.gettempdir()
        # make the webDir absolute, to hide path joins of relative paths
        self.webDir = self.webDir.expand().abspath()
        # If the configDir doesn't exist (as it may be a default setting with a
        # new installation) create it
        if not self.configDir.exists():
            self.configDir.mkdir()
		
        if not G.application.standalone: 
             #FM: Copy styles         
            if not os.path.exists(self.stylesDir) or not os.listdir(self.stylesDir):
                self.copyStyles() 
            else:
                self.updateStyles()                      
        else:
            if G.application.portable:
                if os.name == 'posix': 
                    self.stylesDir      = Path(self.webDir/'..'/'..'/'..'/'style')
                else: 
                    self.stylesDir      = Path(self.webDir/'..'/'style')
                if not os.path.exists(self.stylesDir) or not os.listdir(self.stylesDir): 
                    self.copyStyles()
            else:
                self.stylesDir     = Path(self.webDir/'style').abspath()
            
               
        # Get the list of recently opened projects
        self.recentProjects = []
        if self.configParser.has_section('recent_projects'):
            recentProjectsSection = self.configParser.recent_projects
            # recentProjectsSection.items() is in the wrong order, keys are alright.
            # Sorting list by key before adding to self.recentProjects, to avoid wrong ordering
            # in Recent Projects menu list
            recentProjectsItems = recentProjectsSection.items();
            recentProjectsItems.sort()
            for key, path in recentProjectsItems:
                self.recentProjects.append(path)
                
        # Load the list of "hidden" iDevices
开发者ID:kohnle-lernmodule,项目名称:exe201based,代码行数:70,代码来源:config.py


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