本文整理汇总了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
示例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)
示例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)})
示例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)