• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python misc.Path类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: from_doc_root_to_app_root

def from_doc_root_to_app_root(jobconf, confObj, doc_root):
    japp_root = jobconf.get("compile-options/paths/app-root", "source")
    app_root = os.path.normpath(os.path.join(confObj.absPath(japp_root), 'index.html'))
    # as soon as app_root and doc_root have a drive letter, the next might fail due to capitalization
    _, _, url_path = Path.getCommonPrefix(doc_root, app_root)
    url_path = Path.posifyPath(url_path)
    return url_path
开发者ID:1and1,项目名称:qooxdoo,代码行数:7,代码来源:MiniWebServer.py


示例2: determineRelPathToSdk

def determineRelPathToSdk(appDir, framework_dir, options):
    relPath = ''
    if sys.platform == 'cygwin':
        if re.match( r'^\.{1,2}\/', appDir):
            relPath = Path.rel_from_to(normalizePath(appDir), framework_dir)
        elif re.match( r'^/cygdrive\b', appDir):
            relPath = Path.rel_from_to(appDir, framework_dir)
        else:
            relPath = Path.rel_from_to(normalizePath(appDir), normalizePath(framework_dir))
    else:
        relPath = Path.rel_from_to(normalizePath(appDir), normalizePath(framework_dir))

    relPath = re.sub(r'\\', "/", relPath)
    if relPath[-1] == "/":
        relPath = relPath[:-1]

    if not os.path.isdir(os.path.join(appDir, relPath)):
        console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
        sys.exit(1)

    if options.type == "contribution":
        #relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", QOOXDOO_VERSION)
        #relPath = re.sub(r'\\', "/", relPath)
        pass

    return relPath
开发者ID:leandrorchaves,项目名称:qooxdoo,代码行数:26,代码来源:create-application.py


示例3: patchSkeleton

def patchSkeleton(dir, framework_dir, options):
    absPath = normalizePath(framework_dir)
    if absPath[-1] == "/":
        absPath = absPath[:-1]

    if sys.platform == 'cygwin':
        if re.match( r'^\.{1,2}\/', dir ):
            relPath = Path.rel_from_to(normalizePath(dir), framework_dir)
        elif re.match( r'^/cygdrive\b', dir):
            relPath = Path.rel_from_to(dir, framework_dir)
        else:
            relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
    else:
        relPath = os.path.relpath(framework_dir, dir)
        #relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))

    relPath = re.sub(r'\\', "/", relPath)
    if relPath[-1] == "/":
        relPath = relPath[:-1]

    if not os.path.isdir(os.path.join(dir, relPath)):
        console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
        sys.exit(1)

    if options.type == "contribution":
        relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", QOOXDOO_VERSION)
        relPath = re.sub(r'\\', "/", relPath)

    for root, dirs, files in os.walk(dir):
        for file in files:
            split = file.split(".")
            if len(split) >= 3 and split[-2] == "tmpl":
                outFile = os.path.join(root, ".".join(split[:-2] + split[-1:]))
                inFile = os.path.join(root, file)
                console.log("Patching file '%s'" % outFile)

                #config = MyTemplate(open(inFile).read())
                config = Template(open(inFile).read())
                out = open(outFile, "w")
                out.write(
                    config.substitute({
                        "Name": options.name,
                        "Namespace": options.namespace,
                        "NamespacePath" : (options.namespace).replace('.', '/'),
                        "REL_QOOXDOO_PATH": relPath,
                        "ABS_QOOXDOO_PATH": absPath,
                        "QOOXDOO_VERSION": QOOXDOO_VERSION,
                        "Cache" : options.cache,
                    }).encode('utf-8')
                )
                out.close()
                os.remove(inFile)

    for root, dirs, files in os.walk(dir):
        for file in [file for file in files if file.endswith(".py")]:
            os.chmod(os.path.join(root, file), (stat.S_IRWXU
                                               |stat.S_IRGRP |stat.S_IXGRP
                                               |stat.S_IROTH |stat.S_IXOTH)) # 0755
开发者ID:unify,项目名称:qooxdoo,代码行数:58,代码来源:create-application.py


示例4: patchSkeleton

def patchSkeleton(dir, framework_dir, options):
    absPath = normalizePath(framework_dir)
    if absPath[-1] == "/":
        absPath = absPath[:-1]

    if sys.platform == 'cygwin':
        if re.match( r'^\.{1,2}\/', dir ):
            relPath = Path.rel_from_to(normalizePath(dir), framework_dir)
        elif re.match( r'^/cygdrive\b', dir):
            relPath = Path.rel_from_to(dir, framework_dir)
        else:
            relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))
    else:
        relPath = Path.rel_from_to(normalizePath(dir), normalizePath(framework_dir))

    relPath = re.sub(r'\\', "/", relPath)
    if relPath[-1] == "/":
        relPath = relPath[:-1]

    if not os.path.isdir(os.path.join(dir, relPath)):
        console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
        sys.exit(1)

    if options.type == "contribution":
        # TODO: in a final release the following "trunk" would need to be changed 
        # to an actual version number like "0.8.3"
        relPath = os.path.join(os.pardir, os.pardir, "qooxdoo", "0.8.3")
        relPath = re.sub(r'\\', "/", relPath)

    for root, dirs, files in os.walk(dir):
        for file in files:
            split = file.split(".")
            if len(split) >= 3 and split[1] == "tmpl":
                outFile = os.path.join(root, split[0] + "." + ".".join(split[2:]))
                inFile = os.path.join(root, file)
                console.log("Patching file '%s'" % outFile)

                config = Template(open(inFile).read())
                out = open(outFile, "w")
                out.write(
                    config.substitute({
                        "Name": options.name,
                        "Namespace": options.namespace,
                        "REL_QOOXDOO_PATH": relPath,
                        "ABS_QOOXDOO_PATH": absPath,
                        "QOOXDOO_VERSION": "0.8.3",
                        "Cache" : options.cache,
                    }).encode('utf-8')
                )
                out.close()
                os.remove(inFile)

    for root, dirs, files in os.walk(dir):
        for file in [file for file in files if file.endswith(".py")]:
            os.chmod(os.path.join(root, file), (stat.S_IRWXU
                                               |stat.S_IRGRP |stat.S_IXGRP
                                               |stat.S_IROTH |stat.S_IXOTH)) # 0755
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:57,代码来源:create-application.py


示例5: getImageId

    def getImageId(imagePath, prefixSpec):
        prefix, altprefix = extractFromPrefixSpec(prefixSpec)
        imageId = imagePath # init
        _, imageId, _ = Path.getCommonPrefix(imagePath, prefix) # assume: imagePath = prefix "/" imageId
        if altprefix:
            imageId   = altprefix + "/" + imageId

        imageId = Path.posifyPath(imageId)
        return imageId
开发者ID:choubayu,项目名称:qooxdoo,代码行数:9,代码来源:Resources.py


示例6: normalizeImgUri

 def normalizeImgUri(uriFromMetafile, trueCombinedUri, combinedUriFromMetafile):
     # normalize paths (esp. "./x" -> "x")
     (uriFromMetafile, trueCombinedUri, combinedUriFromMetafile) = map(os.path.normpath,
                                             (uriFromMetafile, trueCombinedUri, combinedUriFromMetafile))
     # get the "wrong" left part of the combined image, as used in the .meta file (in mappedUriPrefix)
     trueUriPrefix, mappedUriPrefix, _ = Path.getCommonSuffix(trueCombinedUri, combinedUriFromMetafile)
     # ...and strip it from clipped image, to get a correct image id (in uriSuffix)
     _, _, uriSuffix = Path.getCommonPrefix(mappedUriPrefix, uriFromMetafile)
     # ...then compose the correct prefix with the correct suffix
     normalUri = os.path.normpath(os.path.join(trueUriPrefix, uriSuffix))
     return normalUri
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:11,代码来源:CodeGenerator.py


示例7: patchSkeleton

def patchSkeleton(dir, name, namespace):
    absPath = normalizePath(FRAMEWORK_DIR)
    if absPath[-1] == "/":
        absPath = absPath[:-1]

    if sys.platform == 'cygwin':
        if re.match( r'^\.{1,2}\/', dir ):
            relPath = Path.rel_from_to(normalizePath(dir), FRAMEWORK_DIR)
        elif re.match( r'^/cygdrive\b', dir):
            relPath = Path.rel_from_to(dir, FRAMEWORK_DIR)
        else:
            relPath = Path.rel_from_to(normalizePath(dir), normalizePath(FRAMEWORK_DIR))
    else:
        relPath = Path.rel_from_to(normalizePath(dir), normalizePath(FRAMEWORK_DIR))

    relPath = re.sub(r'\\', "/", relPath)
    if relPath[-1] == "/":
        relPath = relPath[:-1]

    if not os.path.isdir(os.path.join(dir, relPath)):
        console.error("Relative path to qooxdoo directory is not correct: '%s'" % relPath)
        sys.exit(1)


    for root, dirs, files in os.walk(dir):
        for file in files:
            split = file.split(".")
            if len(split) >= 3 and split[1] == "tmpl":
                outFile = os.path.join(root, split[0] + "." + ".".join(split[2:]))
                inFile = os.path.join(root, file)
                console.log("Patching file '%s'" % outFile)

                config = Template(open(inFile).read())
                out = open(outFile, "w")
                out.write(
                    config.substitute({
                        "Name": name,
                        "Namespace": namespace,
                        "REL_QOOXDOO_PATH": relPath,
                        "ABS_QOOXDOO_PATH": absPath,
                        "QOOXDOO_VERSION": "0.8.1"
                    })
                )
                out.close()
                os.remove(inFile)

    for root, dirs, files in os.walk(dir):
        for file in [file for file in files if file.endswith(".py")]:
            os.chmod(os.path.join(root, file), 0755)
开发者ID:StephanHoyer,项目名称:DJsAdmin,代码行数:49,代码来源:create-application.py


示例8: filter

 def filter(respath):
     respath = Path.posifyPath(respath)
     for res in self._resList:
         mo = res.search(respath)  # this might need a better 'match' algorithm
         if mo:
             return True
     return False
开发者ID:flomotlik,项目名称:grails-qooxdoo,代码行数:7,代码来源:ResourceHandler.py


示例9: generateBootScript

        def generateBootScript(bootPackage=""):

            def packagesOfFiles(fileUri, packages):
                # returns list of lists, each containing destination file name of the corresp. part
                # npackages = [['script/gui-0.js'], ['script/gui-1.js'],...]
                npackages = []
                file = os.path.basename(fileUri)
                for packageId in range(len(packages)):
                    packageFileName = self._resolveFileName(file, variants, settings, packageId)
                    npackages.append((packageFileName,))
                return npackages

            self._console.info("Generating boot script...")
            bootBlocks = []

            # For resource list
            resourceUri = compConf.get('uris/resource', 'resource')
            resourceUri = Path.posifyPath(resourceUri)

            globalCodes = self.generateGlobalCodes(libs, translationMaps, settings, variants, format, resourceUri, scriptUri)

            filesPackages = packagesOfFiles(fileUri, packages)
            bootBlocks.append(self.generateBootCode(parts, filesPackages, boot, variants, settings, bootPackage, globalCodes, "build", format))

            if format:
                bootContent = "\n\n".join(bootBlocks)
            else:
                bootContent = "".join(bootBlocks)

            return bootContent
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:30,代码来源:CodeGenerator.py


示例10: _computeResourceUri

    def _computeResourceUri(self, lib, resourcePath, rType="class", appRoot=None):

        if 'uri' in lib:
            libBaseUri = Uri(lib['uri'])
        elif appRoot:
            libBaseUri = Uri(Path.rel_from_to(self._config.absPath(appRoot), lib['path']))
        else:
            raise RuntimeError, "Need either lib['uri'] or appRoot, to calculate final URI"
        #libBaseUri = Uri(libBaseUri.toUri())

        if rType in lib:
            libInternalPath = OsPath(lib[rType])
        else:
            raise RuntimeError, "No such resource type: \"%s\"" % rType

        # process the second part of the target uri
        uri = libInternalPath.join(resourcePath)
        uri = Uri(uri.toUri())

        libBaseUri.ensureTrailingSlash()
        uri = libBaseUri.join(uri)
        # strip dangling "/", e.g. when we have no resourcePath
        uri.ensureNoTrailingSlash()

        return uri
开发者ID:MatiasNAmendola,项目名称:meyeOS,代码行数:25,代码来源:CodeGenerator.py


示例11: _scanResourcePath

    def _scanResourcePath(self, path):
        if not os.path.exists(path):
            raise ValueError("The given resource path does not exist: %s" % path)

        self._console.debug("Scanning resource folder...")

        path = os.path.abspath(path)
        lib_prefix_len = len(path)
        if not path.endswith(os.sep):
            lib_prefix_len += 1

        for root, dirs, files in filetool.walk(path):
            # filter ignored directories
            for dir in dirs:
                if self._ignoredDirectories.match(dir):
                    dirs.remove(dir)

            for file in files:
                fpath = os.path.join(root, file)
                fpath = os.path.normpath(fpath)
                if Image.isImage(fpath):
                    if CombinedImage.isCombinedImage(fpath):
                        res = CombinedImage(fpath)
                    else:
                        res = Image(fpath)
                    res.analyzeImage()
                else:
                    res = Resource(fpath)
                
                res.id = Path.posifyPath(fpath[lib_prefix_len:])
                res.library= self

                self.resources.add(res)

        return
开发者ID:salmon-charles,项目名称:qooxdoo-build-tool,代码行数:35,代码来源:Library.py


示例12: runCopyFiles

def runCopyFiles(jobconf, confObj):
    # Copy application files
    if not jobconf.get("copy-files/files", False):
        return
    console = Context.console

    filePatts = jobconf.get("copy-files/files", [])
    if filePatts:
        buildRoot = jobconf.get("copy-files/target", "build")
        buildRoot = confObj.absPath(buildRoot)
        sourceRoot = jobconf.get("copy-files/source", "source")
        sourceRoot = confObj.absPath(sourceRoot)
        console.info("Copying application files...")
        console.indent()
        for patt in filePatts:
            appfiles = glob.glob(os.path.join(sourceRoot, patt))
            for srcfile in appfiles:
                console.debug("copying %s" % srcfile)
                srcfileSuffix = Path.getCommonPrefix(sourceRoot, srcfile)[2]
                destfile = os.path.join(buildRoot, srcfileSuffix)
                if os.path.isdir(srcfile):
                    destdir = destfile
                else:
                    destdir = os.path.dirname(destfile)
                _copyResources(srcfile, destdir)

        console.outdent()
开发者ID:karsta60,项目名称:qooxdoo,代码行数:27,代码来源:FileSystem.py


示例13: getSavePath

    def getSavePath(self, urlRoot, fileRoot, currUrl):
        savePath = pathFrag = ""
        # pathFrag = currUrl - urlRoot; assert currUrl > urlRoot
        assert currUrl.startswith(urlRoot)  # only consider urls from the same root
        (pre,sfx1,sfx2) = Path.getCommonPrefix(urlRoot, currUrl)
        pathFrag = sfx2
        savePath = os.path.join(fileRoot, pathFrag)

        return savePath
开发者ID:HelderMagalhaes,项目名称:qooxdoo,代码行数:9,代码来源:Wget.py


示例14: assetIdFromPath

    def assetIdFromPath(self, resource, lib):
        def extractAssetPart(libresuri, imguri):
            pre,libsfx,imgsfx = Path.getCommonPrefix(libresuri, imguri) # split libresuri from imguri
            if imgsfx[0] == os.sep: imgsfx = imgsfx[1:]  # strip leading '/'
            return imgsfx                # use the bare img suffix as its asset Id

        librespath = os.path.normpath(os.path.join(lib['path'], lib['resource']))
        assetId = extractAssetPart(librespath, resource)
        assetId = Path.posifyPath(assetId)
        return assetId
开发者ID:mengu,项目名称:grooxdoo,代码行数:10,代码来源:ResourceHandler.py


示例15: resourceValue

        def resourceValue(r):
            # create a pair res = [path, uri] for this resource...
            rsource = os.path.normpath(r)  # normalize "./..."
            relpath = (Path.getCommonPrefix(libObj._resourcePath, rsource))[2]
            if relpath[0] == os.sep:  # normalize "/..."
                relpath = relpath[1:]
            ruri = (self._genobj._computeResourceUri(lib, relpath, rType='resource', 
                                                        appRoot=self._genobj.approot))

            return (rsource, ruri)
开发者ID:flomotlik,项目名称:grails-qooxdoo,代码行数:10,代码来源:ResourceHandler.py


示例16: _scanResourcePath

    def _scanResourcePath(self):
        resources = set()
        if self.resourcePath is None:
            return resources
        if not os.path.isdir(os.path.join(self.path,self.resourcePath)):
            self._console.info("Lib<%s>: Skipping non-existing resource path" % self.namespace)
            return resources

        path = os.path.join(self.path,self.resourcePath)
        self._console.debug("Scanning resource folder...")

        path = os.path.abspath(path)
        lib_prefix_len = len(path)
        if not path.endswith(os.sep):
            lib_prefix_len += 1

        for root, dirs, files in filetool.walk(path):
            # filter ignored directories
            for dir in dirs:
                if self._ignoredDirEntries.match(dir):
                    dirs.remove(dir)

            for file in files:
                if self._ignoredDirEntries.match(file):
                    continue
                fpath = os.path.join(root, file)
                fpath = os.path.normpath(fpath)
                if Image.isImage(fpath):
                    if CombinedImage.isCombinedImage(fpath):
                        res = CombinedImage(fpath)
                    else:
                        res = Image(fpath)
                    res.analyzeImage()
                elif FontMap.isFontMap(fpath):
                    res = FontMap(fpath)
                else:
                    res = Resource(fpath)

                res.set_id(Path.posifyPath(fpath[lib_prefix_len:]))
                res.library= self

                resources.add(res)

        self._console.indent()
        self._console.debug("Found %s resources" % len(resources))
        self._console.outdent()
        return resources
开发者ID:aspectit,项目名称:qooxdoo,代码行数:47,代码来源:Library.py


示例17: findLibResources

    def findLibResources(self, lib, filter=None):

        def getCache(lib):
            cacheId = "resinlib-%s" % lib._path
            liblist = self._genobj._cache.read(cacheId, dependsOn=None, memory=True)
            return liblist, cacheId

        def isSkipFile(f):
            if [x for x in map(lambda x: re.search(x, f), ignoredFiles) if x!=None]:
                return True
            else:
                return False

        # - Main --------------------------------------------------------------
        cacheList    = []  # to poss. populate cache
        cacheId      = ""  # will be filled in getCache()
        ignoredFiles = [r'\.meta$',]  # files not considered as resources

        # create wrapper object
        libObj = Library(lib, self._genobj._console)
        # retrieve list of library resources
        libList, cacheId = getCache(libObj)
        if libList:
            inCache = True
        else:
            libList = libObj.scanResourcePath()
            inCache = False

        # go through list of library resources and add suitable
        for resource in libList:
            # scanResourcePath() yields absolute paths to a resource, but
            # we only want to match against the 'resource' part of it
            resourcePart = Path.getCommonPrefix(libObj._resourcePath, resource)[2]
            if not inCache:
                cacheList.append(resource)
            if isSkipFile(resource):
                continue
            elif (filter and not filter(resourcePart)):
                continue
            else:
                yield resource

        if not inCache:
            # cache write
            self._genobj._cache.write(cacheId, cacheList, memory=True, writeToFile=False)

        return
开发者ID:mengu,项目名称:grooxdoo,代码行数:47,代码来源:ResourceHandler.py


示例18: processCombinedImg

        def processCombinedImg(data, meta_fname, combinedImageUri, combinedImageShortUri, combinedImageObject):
            # make sure lib and type info for the combined image are present
            assert combinedImageObject.lib, combinedImageObject.type

            # see if we have cached the contents (json) of this .meta file
            cacheId = "imgcomb-%s" % meta_fname
            imgDict = self._cache.read(cacheId, meta_fname)
            if imgDict == None:
                mfile = open(meta_fname)
                imgDict = simplejson.loads(mfile.read())
                mfile.close()
                self._cache.write(cacheId, imgDict)

            # now loop through the dict structure from the .meta file
            for imagePath, imageSpec_ in imgDict.items():
                # sort of like this: imagePath : [width, height, type, combinedUri, off-x, off-y]

                imageObject = ImgInfoFmt(imageSpec_) # turn this into an ImgInfoFmt object, to abstract from representation in .meta file and loader script

                # have to normalize the uri's from the meta file
                #imageUri = normalizeImgUri(imagePath, combinedImageUri, imageObject.mappedId)
                imageUri = imagePath

                ## replace lib uri with lib namespace in imageUri
                imageShortUri = extractAssetPart(librespath, imageUri)
                imageShortUri = Path.posifyPath(imageShortUri)

                # now put all elements of the image object together
                imageObject.mappedId = combinedImageShortUri        # correct the mapped uri of the combined image
                imageObject.lib      = combinedImageObject.lib
                imageObject.mtype    = combinedImageObject.type
                imageObject.mlib     = combinedImageObject.lib

                # and store it in the data structure
                data[imageShortUri]  = imageObject.flatten()  # this information takes precedence over existing

            return
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:37,代码来源:CodeGenerator.py


示例19: replaceWithNamespace

 def replaceWithNamespace(imguri, liburi, libns):
     pre,libsfx,imgsfx = Path.getCommonPrefix(liburi, imguri)
     if imgsfx[0] == os.sep: imgsfx = imgsfx[1:]  # strip leading '/'
     imgshorturi = os.path.join("${%s}" % libns, imgsfx)
     return imgshorturi
开发者ID:mikegr,项目名称:lectorious-grails-qooxdoo,代码行数:5,代码来源:CodeGenerator.py


示例20: file2package

def file2package(fname, rootname):
    fileid = Path.getCommonPrefix(rootname, fname)[2]
    fileid = os.path.splitext(fileid)[0] # strip .py
    return fileid.replace(os.sep, '.')
开发者ID:1and1,项目名称:qooxdoo,代码行数:4,代码来源:generator_api.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python ExtMap.ExtMap类代码示例发布时间:2022-05-27
下一篇:
Python misc.Misc类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap