contexthelper.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:fabric-test 作者: hyperledger 项目源码 文件源码
def getTmpPathForName(self, name, extension=None, copyFromCache=False, path_relative_to_tmp=''):
        'Returns the tmp path for a file, and a flag indicating if the file exists. Will also check in the cache and copy to tmp if copyFromCache==True'
        unicodeName = unicode(name)
        dir_path = os.path.join(self.getTmpProjectPath(), path_relative_to_tmp)
        if not os.path.isdir(dir_path):
            os.makedirs(dir_path)
        slugifiedName = ".".join([slugify(unicodeName), extension]) if extension else slugify(unicodeName)
        tmpPath = os.path.join(dir_path, slugifiedName)
        fileExists = False
        if os.path.isfile(tmpPath):
            # file already exists in tmp path, return path and exists flag
            fileExists = True
        elif copyFromCache:
            # See if the file exists in cache, and copy over to project folder.
            cacheFilePath = os.path.join(self.getCachePath(), slugifiedName)
            if os.path.isfile(cacheFilePath):
                shutil.copy(cacheFilePath, tmpPath)
                fileExists = True
        return (tmpPath, fileExists)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号