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


Python Path.makedirs方法代码示例

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


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

示例1: main

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
def main():
    if len(sys.argv) < 2:
        print 'Usage: %s [version] [--install] [--local|username password]' % sys.argv[0]
        print 'Where [version] is the branch you want to checkout'
        print 'and username and password are for your eduforge account'
        print 'Eg. %s 0.7 --local' % sys.argv[0]
    else:
        version = sys.argv[1]
        branch = 'http://exe.cfdl.auckland.ac.nz/svn/exe/branches/%s' % version
        origDir = Path(sys.argv[0]).abspath().dirname()
        tmp = TempDirPath()
        os.chdir(tmp)
        os.system('svn export %s exe' % branch)
        (origDir/'../../exe/webui/firefox').copytree(tmp/'exe/exe/webui/firefox')
        os.chdir(tmp/'exe')
        tarball = Path('../exe-%s-source.tgz' % version).abspath()
        os.system('tar czf %s *' % tarball)
        os.chdir(tmp)
        if '--local' not in sys.argv:
            try:
                from paramiko import Transport
            except ImportError:
                print 'To upload you need to install paramiko python library from:'
                print 'http://www.lag.net/paramiko'
                sys.exit(2)
            from socket import socket, gethostbyname
            s = socket()
            s.connect((gethostbyname('shell.eduforge.org'), 22))
            t = Transport(s)
            t.connect()
            t.auth_password(sys.argv[-2], sys.argv[-1])
            f = t.open_sftp_client()
            f.chdir('/home/pub/exe')
            f.put(tarball.encode('utf8'), tarball.basename().encode('utf8'))
        if os.getuid() == 0:
            tarball.copyfile('/usr/portage/distfiles/' + tarball.basename())
        os.chdir(tmp/'exe/installs/gentoo')
        newEbuildFilename = Path('exe-%s.ebuild' % version).abspath()
        if not newEbuildFilename.exists():
            Path('exe-0.7.ebuild').copy(newEbuildFilename)
        if os.getuid() == 0:
            ebuildDir = Path('/usr/local/portage/dev-python/exe')
            if ebuildDir.exists():
                ebuildDir.rmtree()
            ebuildDir.makedirs()
            os.chdir(ebuildDir)
            newEbuildFilename.copy(ebuildDir)
            filesDir = ebuildDir/'files'
            filesDir.makedirs()
            Path(tmp/'exe/installs/gentoo/all-config.patch').copy(filesDir)
            if '--local' not in sys.argv:
                oldTarball = Path('/usr/portage/distfiles/')/tarball.basename()
                if oldTarball.exists():
                    oldTarball.remove()
                os.environ['GENTOO_MIRRORS']=''
                os.system('ebuild %s fetch' % newEbuildFilename.basename())
            os.system('ebuild %s manifest' % newEbuildFilename.basename())
            os.system('ebuild %s digest' % newEbuildFilename.basename())
            if '--install' in sys.argv:
                os.system('ebuild %s install' % newEbuildFilename.basename())
开发者ID:,项目名称:,代码行数:62,代码来源:

示例2: exportIpod

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def exportIpod(self, client, filename):
     """
     Export 'client' to an iPod Notes folder tree
     'webDir' is just read from config.webDir
     """
     try:
         # filename is a directory where we will export the notes to
         # We assume that the user knows what they are doing
         # and don't check if the directory is already full or not
         # and we just overwrite what's already there
         filename = Path(filename)
         # Append the package name to the folder path if necessary
         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:
             client.alert(_(u'Folder name %s already exists. '
                             'Please choose another one or delete existing one then try again.') % filename)           
             return 
         # Now do the export
         ipodExport = IpodExport(self.config, filename)
         ipodExport.export(self.package)
     except Exception, e:
         client.alert(_('EXPORT FAILED!\n%s') % str(e))
         raise
开发者ID:giorgil2,项目名称:eXe,代码行数:34,代码来源:mainpage.py

示例3: exportWebSite

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def exportWebSite(self, client, filename, stylesDir):
     """
     Export 'client' to a web site,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     """
     try:
         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:
             client.alert(_(u'Folder name %s already exists. '
                             'Please choose another one or delete existing one then try again.') % filename)           
             return 
         websiteExport = WebsiteExport(self.config, stylesDir, filename)
         websiteExport.export(self.package)
     except Exception, e:
         client.alert(_('EXPORT FAILED!\n%s') % str(e))
         raise
开发者ID:,项目名称:,代码行数:29,代码来源:

示例4: exportSinglePage

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [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,代码来源:

示例5: makeMO

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
def makeMO(applicationDirectoryPath, targetDir=None, applicationDomain=None, verbose=0, forceEnglish=0):
    """Compile the Portable Object files into the Machine Object stored in the right location.
    makeMO converts all translated language-specific PO files located inside 
    the  application directory into the binary .MO files stored inside the 
    LC_MESSAGES sub-directory for the found locale files.
    makeMO searches for all files that have a name of the form 'app_xx.po' 
    inside the application directory specified by the first argument.  The 
    'app' is the application domain name (that can be specified by the 
    applicationDomain argument or is taken from the directory name). The 'xx' 
    corresponds to one of the ISO 639 two-letter language codes.
    makeMo stores the resulting files inside a sub-directory of `targetDir` 
    called xx/LC_MESSAGES where 'xx' corresponds to the 2-letter language 
    code.
    """
    if targetDir is None:
        targetDir = "exe/locale"
    if verbose:
        print "Target directory for .mo files is: %s" % targetDir
    targetDir = Path(targetDir)
    if applicationDomain is None:
        applicationName = fileBaseOf(applicationDirectoryPath, withPath=0)
    else:
        applicationName = applicationDomain
    currentDir = os.getcwd()
    os.chdir(applicationDirectoryPath)
    for filename in targetDir.glob("*_*.po"):
        langCode = filename.split("_", 1)[1].split(".", 1)[0]
        mo_targetDir = Path("%s/%s/LC_MESSAGES" % (targetDir, langCode))
        if not mo_targetDir.exists():
            mo_targetDir.makedirs()
        cmd = "msgfmt --output-file=%s.mo %s" % (mo_targetDir / applicationName, filename)
        if verbose:
            print cmd
        os.system(cmd)
    os.chdir(currentDir)
开发者ID:,项目名称:,代码行数:37,代码来源:

示例6: get_base_path_for_user

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def get_base_path_for_user(self, username):
     """
     Returns the base directory for the user
     Parameters
     ----------
     username : str
     The username to get the base path for
     """
     dir_path = self.backend_provider.get_base_path_for_user(username)
     if self.auth_config['autocreate_user_path'] == "1":
         path_obj = Path(dir_path)
         if not path_obj.exists():
             path_obj.makedirs()
     
     return dir_path
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:17,代码来源:exebackendservice.py

示例7: exportSinglePage

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def exportSinglePage(self, client, filename, webDir, stylesDir, \
                      printFlag):
     """
     Export 'client' to a single web page,
     'webDir' is just read from config.webDir
     'stylesDir' is where to copy the style sheet information from
     'printFlag' indicates whether or not this is for print 
                 (and whatever else that might mean)
     """
     try:
         imagesDir    = webDir.joinpath('images')
         scriptsDir   = webDir.joinpath('scripts')
         templatesDir = webDir.joinpath('templates')
         # filename is a directory where we will export the website to
         # We assume that the user knows what they are doing
         # and don't check if the directory is already full or not
         # and we just overwrite what's already there
         filename = Path(filename)
         # Append the package name to the folder path if necessary
         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:
             client.alert(_(u'Folder name %s already exists. '
                             'Please choose another one or delete existing one then try again.') % filename)           
             return 
         # Now do the export
         singlePageExport = SinglePageExport(stylesDir, filename, \
                                      imagesDir, scriptsDir, templatesDir)
         singlePageExport.export(self.package, printFlag)
     except Exception, e:
         client.alert(_('SAVE FAILED!\n%s' % str(e)))
         raise
开发者ID:giorgil2,项目名称:eXe,代码行数:42,代码来源:mainpage.py

示例8: export_website

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def export_website(self, pkg, outputf):
     outputfp = Path(outputf)
     outputfp.makedirs()
     websiteExport = WebsiteExport(self.config, self.styles_dir, outputf)
     websiteExport.export(pkg)
开发者ID:manamani,项目名称:iteexe,代码行数:7,代码来源:cmdlineexporter.py

示例9: copyFiles

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
    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")
        langFile.write(common.getJavaScriptStrings(False))
        langFile.close()

        # 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')

        #JR Metemos los reproductores necesarios
        self.compruebaReproductores(self.page.node)


        if package.license == "license GFDL":
            # include a copy of the GNU Free Documentation Licence
            ext = 'html'
            if G.application.config.cutFileName == "1":
                ext = 'htm'
            (self.templatesDir/'fdl' + '.' + ext).copyfile(self.outputDir/'fdl' + '.' + ext)
开发者ID:exelearning,项目名称:iteexe,代码行数:75,代码来源:singlepageexport.py

示例10: export

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

        self.metadataType = package.exportMetadataType


        # Copy the style files to the output dir
        # But not nav.css
        styleFiles = [self.styleDir/'..'/'popup_bg.gif']
        styleFiles += self.styleDir.files("*.*")
        if "nav.css" in styleFiles:
            styleFiles.remove("nav.css")
        self.styleDir.copylist(styleFiles, outputDir)

        # 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)

        listCSSFiles=getFilesCSSToMinify('ims', self.styleDir)
        exportMinFileCSS(listCSSFiles, 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, self.pages)

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

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

        # 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')

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

        listFiles=getFilesJSToMinify('ims', self.scriptsDir)
        exportMinFileJS(listFiles, outputDir)

        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
        hasFX             = False
        hasSH             = False
        hasGames          = False
        hasElpLink        = False
        hasWikipedia      = False
        isBreak           = False
        hasInstructions   = False
        hasMediaelement   = False
        hasTooltips       = False
        hasABCMusic       = False
        listIdevicesFiles = []

        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 hasMediaelement and hasTooltips and hasABCMusic):
#.........这里部分代码省略.........
开发者ID:exelearning,项目名称:iteexe,代码行数:103,代码来源:imsexport.py

示例11: copyFiles

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
    def copyFiles(self, package, outputDir):
        """
        Copy all the files used by the website.
        """

        if os.path.isdir(self.stylesDir):
            # Copy the style files to the output dir
            styleFiles = [self.stylesDir/'..'/'popup_bg.gif']
            styleFiles += self.stylesDir.files("*.*")
            self.stylesDir.copylist(styleFiles, outputDir)

        # 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)

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

        # copy script files.
        my_style = G.application.config.styleStore.getStyle(package.style)
        # jQuery
        listFiles=[]
        listOutFiles=[]
        if my_style.hasValidConfig:
            if my_style.get_jquery() == True:
                jsFile = (self.scriptsDir/'exe_jquery.js')
                jsFile.copyfile(outputDir/'exe_jquery.js')
        else:
            listFiles+=[self.scriptsDir/'exe_jquery.js']
            listOutFiles+=[outputDir/'exe_jquery.js']

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

        # Create lang file
        langFile = open(outputDir + '/common_i18n.js', "w")
        langFile.write(common.getJavaScriptStrings(False))
        langFile.close()
        #dT = common.getExportDocType()
        dT=common.getExportDocType();
        if dT == "HTML5":
            jsFile = (self.scriptsDir/'exe_html5.js')
            jsFile.copyfile(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(outputDir/'favicon.ico')

        # 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
        hasMediaelement   = False
        hasTooltips       = False
        hasABCMusic       = False
        listIdevicesFiles = []

        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 hasMediaelement and hasTooltips and hasABCMusic):
                    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
                if not hasGallery:
                    hasGallery = common.ideviceHasGallery(idevice)
                if not hasFX:
                    hasFX = common.ideviceHasFX(idevice)
                if not hasSH:
#.........这里部分代码省略.........
开发者ID:exelearning,项目名称:iteexe,代码行数:103,代码来源:websiteexport.py

示例12: export

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [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,代码来源:

示例13: loadSettings

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
    def loadSettings(self):
        """
        Loads the settings from the exe.conf file.
        Overrides the defaults set in __init__
        """
        # Set up the parser so that if a certain value is not in the config
        # file, it will use the value from our default values
        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.port           = int(system.port)
            self.browser        = None if system.browser == u"None" else system.browser
            self.appMode = system.appMode
            
            
            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.readabilityPresetsDir = Path(self.configDir)/'readability-presets'
                self.jsDir          = Path(system.jsDir)
            else:
                self.stylesDir      = Path(self.webDir/'style').abspath()
                self.readabilityPresetsDir = Path(self.webDir/'readability').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()
            
        try:
            from exe.engine.locationbuttons  import LocationButtons
            library_path = Path(LocationButtons().get_user_doc_path()/'eXeLearning'/'Library')
            if not library_path.exists():
                library_path.makedirs()
            
            template_path = Path(LocationButtons().get_user_doc_path()/'eXeLearning'/'Templates')
            if not template_path.exists():
                template_path.makedirs()    
                self.copyElpTemplates(str(template_path))
            
        except:
            print "Error creating library dir"
        
        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()     
                
            #MD readability presets dir
            if not os.path.exists(self.readabilityPresetsDir) or not os.listdir(self.readabilityPresetsDir):
                self.copyReadabilityPresets()
            else:
                #self.updateReadabilityPresets()
                pass
                 
        else:
            if G.application.portable:
                if os.name == 'posix': 
                    self.stylesDir      = Path(self.webDir/'..'/'..'/'..'/'style')
                    self.readabilityPresetsDir = Path(self.webDir/'..'/'..'/'..'/'readability-presets')
                else: 
                    self.stylesDir      = Path(self.webDir/'..'/'style')
                    self.readabilityPresetsDir = Path(self.webDir/'..'/'readability-presets')
                if not os.path.exists(self.stylesDir) or not os.listdir(self.stylesDir): 
                    self.copyStyles()
                else:
                    self.updateStyles()
                    
                if not os.path.exists(self.readabilityPresetsDir) or not os.listdir(self.readabilityPresetsDir):
                    self.copyReadabilityPresets()
                
                #TODO: Update copy    
                
            else:
                self.stylesDir     = Path(self.webDir/'style').abspath()
#.........这里部分代码省略.........
开发者ID:UstadMobile,项目名称:exelearning-ustadmobile-work,代码行数:103,代码来源:config.py

示例14: __init__

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
 def __init__(self, filename = None, name = None):
     '''
     Constructor
     '''
     self.filename = filename
     if name is not None:
         self.name = name
     else:
         self.name = os.path.basename(filename)
     
     self.resourceDir = TempDirPath()
     
     #TODO: inspect filenames for untrusted entries e.g. .. and /
     zippedFile = zipfile.ZipFile(filename, "r")
     for fn in zippedFile.namelist():
         #check to make sure that we have the required directories
         Dir = None
         if fn[-1:] == '/':
             Dir = Path(self.resourceDir/fn)
         else:
             Dir = Path(self.resourceDir/os.path.dirname(fn))
         
         if not Dir.exists():
             Dir.makedirs()
             
             
         Fn = Path(self.resourceDir/fn)
         
         if not Fn.isdir():
             outFile = open(self.resourceDir/fn, "wb")
             outFile.write(zippedFile.read(fn))
             outFile.flush()
             outFile.close()
             file_info = zippedFile.getinfo(fn)
             mod_time =time.mktime(file_info.date_time+(0,0,-1))
             os.utime(self.resourceDir/fn, (time.time(), mod_time))
     
     #update files here...
     
     ocf_str = open(self.resourceDir/"META-INF/container.xml", 'r').read()
     self.ocf = EPUBOCF(ocf_doc = ocf_str)
     self.opfs = []
     for container in self.ocf.root_containers:
         if container.media_type == "application/oebps-package+xml":
             opf_path = os.path.join(self.resourceDir, container.full_path)
             opf_str = open(opf_path, 'r').read()
             self.opfs.append(EPUBOPF(opf_path, opf_str = opf_str, 
                                      container_path = container.full_path, package = self)) 
     
     
     # for now we handle one OPF in a package
     self.main_opf = self.opfs[0]
     self.main_manifest = self.main_opf.manifest
     self.root = self.main_opf.get_navigation()
     
     if EPUBPackage.UPDATE_ALL_ON_OPEN:
         self.main_opf.resource_manager.update_all_pages()
     
     self.currentNode = self.root
     self.tincan_manager = TinCanXMLManager(self)
     self.isChanged = False
开发者ID:UstadMobile,项目名称:eXePUB,代码行数:63,代码来源:epubpackage.py

示例15: Path

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import makedirs [as 别名]
"""
Get's all external libs into extern directory
"""

import sys, os

if "." not in sys.path:
    sys.path.insert(0, ".")
import urllib2
import tarfile
from shutil import copyfileobj
from exe.engine.path import Path

EXTERN_DIR = Path("extern/src")
if not EXTERN_DIR.exists():
    EXTERN_DIR.makedirs()


def download(url, filename=None):
    """
    Downloads a url to a filename.
    True if it is downloaded.
    """
    # If already exists, just return the existing file
    if filename and os.path.isfile(filename):
        return open(filename, "rb")
    req = urllib2.Request(url=url)
    input = urllib2.urlopen(req)
    if filename:
        output = file(filename, "wb")
        copyfileobj(input, output)
开发者ID:,项目名称:,代码行数:33,代码来源:


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