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


Python Path.isfile方法代码示例

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


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

示例1: __setConfigPath

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def __setConfigPath(self):
     """
     sets self.configPath to the filename of the config file that we'll
     use.
     In descendant classes set self.configFileOptions to a list
     of directories where the configDir should be in order of preference.
     If no config files can be found in these dirs, it will
     force creation of the config file in the top dir
     """
     self.configPath = None
     configFileOptions = map(Path, self._getConfigPathOptions())
     if "EXECONF" in os.environ:
         envconf = Path(os.environ["EXECONF"])
         if envconf.isfile():
             self.configPath = os.environ["EXECONF"]
     if self.configPath is None:
         for confPath in configFileOptions:
             if confPath.isfile():
                 self.configPath = confPath
                 break
         else:
             self.configPath = configFileOptions[0]
             folder = self.configPath.abspath().dirname()
             if not folder.exists():
                 folder.makedirs()
             self.configPath.touch()
     self.configParser.read(self.configPath)
     self.configParser.autoWrite = True
开发者ID:,项目名称:,代码行数:30,代码来源:

示例2: StandaloneConfig

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
class StandaloneConfig(Config):
    """
    The StandaloneConfig overrides the Config class with ready-to-run specific
    configuration
    """
    def _overrideDefaultVals(self):
        """
        Setup with our default settings
        """
        self.exePath = Path(sys.argv[0])
        if self.exePath.isfile():
            self.exePath = self.exePath.dirname()
        exePath = self.exePath
        self.webDir        = exePath
        self.dataDir       = exePath/'packages'
        if not self.dataDir.exists():
            self.dataDir.makedirs()
        self.configDir     = exePath/'config'
        self.localeDir     = exePath/'locale'
        self.xulrunnerPath = exePath/'xulrunner/xulrunner'
        self.styles        = []
        self.browserPath = exePath/'firefox'/'firefox.exe'
    def _getConfigPathOptions(self):
        """
        Returns the best places for a linux config file
        """
        return [self.configDir/'exe.conf']
开发者ID:,项目名称:,代码行数:29,代码来源:

示例3: testUpgradeTo0_20

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def testUpgradeTo0_20(self):
     """
     Creates a package similar to what 0.19 would
     and tests if it upgrades ok
     """
     fn = Path('0.19 resources upgrade test.elp')
     assert fn.isfile() or fn.islink()
     package = self.package.__class__.load(fn)
     assert hasattr(package, 'resources')
     assert len(package.resources) == 8, len(package.resources)
     for checksum, resources in package.resources.items():
         storageNames = []
         userNames = []
         for res in resources:
             storageNames.append(res.storageName)
             userNames.append(res.userName)
         assert len(set(storageNames)) == 1, 'Two identical resources have different storage names:\n%s' % storageNames
     allResourceNames = []
     for reses in package.resources.values():
         allResourceNames.append(reses[0].storageName)
     filenames = [path.basename() for path in package.resourceDir.files()]
     withoutDups = set(filenames) - set(allResourceNames)
     assert withoutDups == set([]), "Duplicate files weren't deleted %s" % withoutDups
     assert len(filenames) == len(allResourceNames)
     assert len(filenames) > 0, 'All resources have been deleted!'
开发者ID:,项目名称:,代码行数:27,代码来源:

示例4: uploadFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
    def uploadFile(self):
        """Store pdf in package, gets sides from pdf, if self.sides
        isn't empty
        """
        filePath = self.path
        log.debug(u"uploadFile " + unicode(filePath))
        if not self.parentNode or not self.parentNode.package:
            log.error("something is wrong with the file")
        ## replace all non-digits and non-usefull stuff with ''
        self.pages = sub("[^\d,-]", "", self.pages)
        if self.pages != "":
            input = PdfFileReader(file(filePath, "rb"))
            lastPage = input.getNumPages() - 1  # last page
            toimport = PdfIdevice.__parseImportPages(self.pages, lastPage)
            log.debug("Parsed pages: " + str(toimport))
            output = PdfFileWriter()

            for page in toimport:
                output.addPage(input.getPage(page))
            log.debug("Found pages to import %s" % toimport)
            tmp = os.tmpnam() + ".pdf"
            log.debug("Tempfile is %s" % tmp)
            outputStream = file(tmp, "wb")
            output.write(outputStream)
            outputStream.close()
            resourceFile = Path(tmp)
            self.file = Resource(self, resourceFile)
            log.debug("Uploaded %s, pages: %s" % (tmp, toimport))
            os.remove(tmp)
            filePath = tmp
        resourceFile = Path(filePath)
        if resourceFile.isfile():
            self.file = Resource(self, resourceFile)
            log.debug(u"uploaded " + self.path)
开发者ID:alendit,项目名称:exeLearning,代码行数:36,代码来源:pdfidevice.py

示例5: setFlash

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def setFlash(self, flashPath):
     """
     Store the image in the package
     Needs to be in a package to work.
     """
     log.debug(u"setFlash "+unicode(flashPath))
     resourceFile = Path(flashPath)
     assert(self.idevice.parentNode,
            'Flash '+self.idevice.id+' has no parentNode')
     assert(self.idevice.parentNode.package,
            'iDevice '+self.idevice.parentNode.id+' has no package')
     if resourceFile.isfile():
         if self.flashResource:
             self.flashResource.delete()
             self.idevice.userResources.remove(self.flashResource)
         try:
             flvDic = FLVReader(resourceFile)
             self.height = flvDic["height"] +30        
             self.width  = flvDic["width"]
             self.flashResource = Resource(self.idevice.parentNode.package,
                                           resourceFile)
             self.idevice.userResources.append(self.flashResource)
         except AssertionError: 
             log.error('File %s is not a flash movie' % resourceFile)
     else:
         log.error('File %s is not a file' % resourceFile)
开发者ID:,项目名称:,代码行数:28,代码来源:

示例6: StandaloneConfig

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
class StandaloneConfig(Config):
    """
    The StandaloneConfig overrides the Config class with ready-to-run specific
    configuration
    """
    
    def _overrideDefaultVals(self):
        """
        Setup with our default settings
        """
        self.exePath = Path(sys.argv[0])
        if self.exePath.isfile():
            self.exePath = self.exePath.dirname()
        exePath = self.exePath
        # Override the default settings
        self.webDir        = exePath
        self.configDir     = exePath/'config'
        self.localeDir     = exePath/'locale'
        self.stylesDir     = Path(exePath/'style').abspath()
        self.styles        = []
        self.lastDir       = exePath

    def _getConfigPathOptions(self):
        """
        Returns the best places for a linux config file
        """
        return [self.configDir/'exe.conf']
开发者ID:Rafav,项目名称:iteexe,代码行数:29,代码来源:standaloneconfig.py

示例7: render_POST

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
    def render_POST(self, request=None):
        log.debug("render_POST")

        lang_only = False

        data = {}
        try:
            clear = False
            if 'clear' in request.args:
                clear = True
                request.args.pop('clear')
            if 'lang_only' in request.args:
                lang_only = True
                request.args.pop('lang_only')
            if 'lom_general_title_string1' in request.args:
                if clear:
                    self.package.setLomDefaults()
                else:
                    self.setLom(request.args)
            elif 'lomes_general_title_string1' in request.args:
                if clear:
                    self.package.setLomEsDefaults()
                else:
                    self.setLomes(request.args)
            else:
                items = request.args.items()
                if 'pp_lang' in request.args:
                    value = request.args['pp_lang']
                    item = ('pp_lang', value)
                    items.remove(item)
                    items.insert(0, item)
                for key, value in items:
                    obj, name = self.fieldId2obj(key)
                    if key in self.booleanFieldNames:
                        setattr(obj, name, value[0] == 'true')
                    else:
                        if key in self.imgFieldNames:
                            path = Path(toUnicode(value[0]))
                            if path.isfile():
                                setattr(obj, name, path)
                                data[key] = getattr(obj, name).basename()
                            else:
                                if getattr(obj, name):
                                    if getattr(obj, name).basename() != path:
                                        setattr(obj, name, None)
                        else:
                            #if name=='docType': common.setExportDocType(toUnicode(value[0]))

                            setattr(obj, name, toUnicode(value[0]))

        except Exception as e:
            log.exception(e)
            return json.dumps({'success': False, 'errorMessage': _("Failed to save properties")})

        if not self.package.isTemplate or not lang_only:
            self.package.isChanged = True

        return json.dumps({'success': True, 'data': data})
开发者ID:exelearning,项目名称:iteexe,代码行数:60,代码来源:propertiespage.py

示例8: uploadNeededScripts

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def uploadNeededScripts(self):
     from exe import globals
     import os,sys
     scriptFileNames = ['jquery-ui-1.10.3.custom.min.js', 'memmatch-0.2.js']
     for scriptName in scriptFileNames:
         from exe import globals 
         scriptSrcFilename = globals.application.config.webDir/"templates"/scriptName
         gameScriptFile = Path(scriptSrcFilename)
         if gameScriptFile.isfile():
             Resource(self, gameScriptFile)
开发者ID:Rafav,项目名称:iteexe,代码行数:12,代码来源:memorymatchidevice.py

示例9: handleTinyMCEimageChoice

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def handleTinyMCEimageChoice(self, client, tinyMCEwin, tinyMCEwin_name, \
                          tinyMCEfield, local_filename, preview_filename):
     """
     Once an image is selected in the file browser that is spawned by the 
     TinyMCE image dialog, copy this file (which is local to the user's 
     machine) into the server space, under a preview directory 
     (after checking if this exists, and creating it if necessary).
     Note that this IS a "cheat", in violation of the client-server 
     separation, but can be done since we know that the eXe server is 
     actually sitting on the client host.
     """
     server_filename = ""
     callback_errors = ""
     errors = 0
     webDir     = Path(self.config.webDir)
     previewDir  = webDir.joinpath('previews')
     if not previewDir.exists():
         log.debug("image previews directory does not yet exist; " \
                 + "creating as %s " % previewDir)
         previewDir.makedirs()
     elif not previewDir.isdir():
         client.alert( \
             _(u'Preview directory %s is a file, cannot replace it') \
             % previewDir)
         log.error("Couldn't preview tinyMCE-chosen image: "+
                   "Preview dir %s is a file, cannot replace it" \
                   % previewDir)
         callback_errors =  "Preview dir is a file, cannot replace"
         errors += 1
     if errors == 0:
         localImagePath = Path(local_filename)
         if not localImagePath.exists() or not localImagePath.isfile():
             client.alert( \
                  _(u'Image file %s is not found, cannot preview it') \
                  % localImagePath)
             log.error("Couldn't find tinyMCE-chosen image: %s" \
                     % localImagePath)
             callback_errors = "Image file %s not found, cannot preview" \
                     % localImagePath
             errors += 1
     try:
         server_filename = previewDir.joinpath(preview_filename);
         log.debug("handleTinyMCEimageChoice copying image from \'"\
                 + local_filename + "\' to \'" \
                 + server_filename.abspath().encode('utf-8') + "\'.");
         shutil.copyfile(local_filename, \
                 server_filename.abspath().encode('utf-8'));
     except Exception, e:
         client.alert(_('SAVE FAILED!\n%s' % str(e)))
         log.error("handleTinyMCEimageChoice unable to copy local image "\
                 +"file to server prevew, error = " + str(e))
         raise
开发者ID:,项目名称:,代码行数:54,代码来源:

示例10: addGameScript

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
    def addGameScript(self):
        from exe import globals
        import os, sys

        scriptSrcFilename = globals.application.config.webDir / "templates" / "hangman.js"
        log.debug("Script filename = " + scriptSrcFilename)

        # assert(self.parentNode,
        #       'Image '+self.id+' has no parentNode')
        # assert(self.parentNode.package,
        #       'iDevice '+self.parentNode.id+' has no package')

        gameScriptFile = Path(scriptSrcFilename)
        if gameScriptFile.isfile():
            Resource(self, gameScriptFile)
开发者ID:,项目名称:,代码行数:17,代码来源:

示例11: uploadFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def uploadFile(self, filePath):
     """
     Store the upload files in the package
     Needs to be in a package to work.
     """ 
     log.debug(u"uploadFile "+unicode(filePath))
     resourceFile = Path(filePath)
     assert(self.parentNode,
            _('file %s has no parentNode') % self.id)
     assert(self.parentNode.package,
            _('iDevice %s has no package') % self.parentNode.id)
     if resourceFile.isfile():
         self.userResources += [ Resource(self.parentNode.package,
                                         resourceFile) ]
     else:
         log.error('File %s is not a file' % resourceFile)
开发者ID:,项目名称:,代码行数:18,代码来源:

示例12: setImage

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def setImage(self, imagePath):
     """
     Store the image in the package
     Needs to be in a package to work.
     """
     log.debug(u"setImage "+unicode(imagePath))
     resourceFile = Path(imagePath)
     assert(self.idevice.parentNode,
            'Image '+self.idevice.id+' has no parentNode')
     assert(self.idevice.parentNode.package,
            'iDevice '+self.idevice.parentNode.id+' has no package')
     if resourceFile.isfile():
         if self.imageResource:
             self.imageResource.delete()
         self.imageResource = Resource(self.idevice, resourceFile)
     else:
         log.error('File %s is not a file' % resourceFile)
开发者ID:,项目名称:,代码行数:19,代码来源:

示例13: uploadFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def uploadFile(self, filePath):
     """
     Store the upload files in the package
     Needs to be in a package to work.
     """ 
     if self.type == "descartes" and not filePath.endswith(".jar"):
         if filePath.find(",") == -1:
             global SCENE_NUM
             SCENE_NUM = 1
         else:
             SCENE_NUM = int(filePath[:filePath.find(",")])
     if self.type == "descartes" and (filePath.endswith(".htm") or filePath.endswith(".html")):
         global url
         url = filePath
         self.appletCode = self.getAppletcodeDescartes(filePath)
         # none scene was found:
         if self.appletCode == '':
             return None
     else:
         log.debug(u"uploadFile "+unicode(filePath))
         resourceFile = Path(filePath)
         assert self.parentNode, _('file %s has no parentNode') % self.id
         assert self.parentNode.package, \
                 _('iDevice %s has no package') % self.parentNode.id
         if resourceFile.isfile():
             self.message = ""
             Resource(self, resourceFile)
             if self.type == "geogebra":
                 self.appletCode = self.getAppletcodeGeogebra(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
             if self.type == "jclic":
                 self.appletCode = self.getAppletcodeJClic(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
             if self.type == "scratch":
                 self.appletCode = self.getAppletcodeScratch(resourceFile.basename().replace(' ','_').replace(')','').replace('(',''))
             if self.type == "descartes":
                 self.appletCode = self.getAppletcodeDescartes(resourceFile.basename())
             ## next code should be used to load in the editor the HTML code of the html file:
             # if self.type == "other":
             #     if filePath.endswith(".html") or filePath.endswith(".htm"):
             #         content = open(filePath, 'r')
             #         str = content.read()
             #         self.appletCode = str
             #         content.close()
             #    else:
             #        log.error('File %s is not a HTML file' % resourceFile)
         else:
             log.error('File %s is not a file' % resourceFile)
开发者ID:RichDijk,项目名称:eXe,代码行数:48,代码来源:appletidevice.py

示例14: setAttachment

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def setAttachment(self, attachmentPath):
     """
     Store the attachment in the package
     Needs to be in a package to work.
     """ 
     log.debug(u"setAttachment "+unicode(attachmentPath))
     resourceFile = Path(attachmentPath)
     assert(self.parentNode,
            _('Attachment %s has no parentNode') % self.id)
     assert(self.parentNode.package,
            _('iDevice %s has no package') % self.parentNode.id)
     if resourceFile.isfile():
         if self.userResources:
             while self.userResources:
                 self.userResources[0].delete()
         Resource(self, resourceFile)
     else:
         log.error('File %s is not a file' % resourceFile)
开发者ID:,项目名称:,代码行数:20,代码来源:

示例15: uploadFile

# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import isfile [as 别名]
 def uploadFile(self, filePath):
     if self.fileResource is not None:
         self.fileResource.delete()
         
     finalName = str(filePath)
     if self.alwaysNameTo is not None:
         from os.path import dirname
         from shutil import copyfile
         dirName = dirname(filePath)
         finalName = dirName + "/" + self.alwaysNameTo
         copyfile(filePath, finalName)
     
     if self.fileDescription.content == "":
         self.fileDescription.content = os.path.basename(filePath)
         
     resourceFile = Path(finalName)
     if resourceFile.isfile():
         self.idevice.message = ""
         self.fileResource = Resource(self.idevice, resourceFile)
开发者ID:Rafav,项目名称:iteexe,代码行数:21,代码来源:extendedfieldengine.py


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