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


Python OSFS.walkfiles方法代码示例

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


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

示例1: detect_format

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import walkfiles [as 别名]
def detect_format(source):
    fs = OSFS(source)
    if fs.walkfiles('/', '*.morph'):
        return 'baserock-morphologies'
    if fs.walkfiles('/', '*.cida'):
        return 'cida-definitions'
    return None
开发者ID:gtristan,项目名称:ybd,代码行数:9,代码来源:wrangler.py

示例2: write_chunk_metafile

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import walkfiles [as 别名]
def write_chunk_metafile(defs, chunk):
    '''Writes a chunk .meta file to the baserock dir of the chunk

    The split rules are used to divide up the installed files for the chunk
    into artifacts in the 'products' list

    '''
    app.log(chunk['name'], 'splitting chunk')
    rules, splits = compile_rules(defs, chunk)

    install_dir = chunk['install']
    fs = OSFS(install_dir)
    files = fs.walkfiles('.', search='depth')
    dirs = fs.walkdirs('.', search='depth')

    for path in files:
        for artifact, rule in rules:
            if rule.match(path):
                splits[artifact].append(path)
                break

    all_files = [a for x in splits.values() for a in x]
    for path in dirs:
        if not any(map(lambda y: y.startswith(path),
                   all_files)) and path != '':
            for artifact, rule in rules:
                if rule.match(path) or rule.match(path + '/'):
                    splits[artifact].append(path)
                    break

    write_metafile(rules, splits, chunk)
开发者ID:gtristan,项目名称:ybd,代码行数:33,代码来源:splitting.py

示例3: list_photos

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import walkfiles [as 别名]
def list_photos(folder):
	try:
		photo_fs = OSFS('~/Pictures/Playground/' + folder)
		photos = []

		for photo in photo_fs.walkfiles():
			if is_photo(photo):
				photos.append(Photo(photo, photo_fs))

		return jsonify(photos)
	except ResourceNotFoundError as err:
		return jsonify({'error': unicode(err)})
开发者ID:jelmervdl,项目名称:photomanager,代码行数:14,代码来源:server.py

示例4: cmd_makeadminpreviews

# 需要导入模块: from fs.osfs import OSFS [as 别名]
# 或者: from fs.osfs.OSFS import walkfiles [as 别名]
    def cmd_makeadminpreviews(self, *params, **options):
        try:
            iconset = params[0]
        except IndexError:
            iconset = ''

        icon_fs = OSFS(settings.MEDIA_ROOT).opendir('iconsets')
        if params:
            icon_fs = icon_fs.opendir(params[0])

        done_dirs = set()
        for path in icon_fs.walkfiles(wildcard='*.png'):
            dirpath = dirname(path)
            png_path = icon_fs.getsyspath(path)
            img = Image.open(png_path).convert('RGBA')
            background_img = Image.new('RGB', img.size, (255, 255, 255))

            background_img.paste(img, None, img)

            new_path = os.path.splitext(png_path)[0] + '.jpg'
            background_img.save(new_path)
            if dirpath not in done_dirs:
                print "Generating admin previews in %s/*" % dirpath
                done_dirs.add(dirpath)            
开发者ID:willmcgugan,项目名称:Locidesktop,代码行数:26,代码来源:icons.py


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