我们从Python开源项目中,提取了以下2个代码示例,用于说明如何使用sqlalchemy.ext()。
def accumulate_size_by_extension(files): d = {} for (ext, size) in files: acc = d.get(ext, AccumulatedSize(ext, 0, 0)) d[ext] = AccumulatedSize(acc.extension, acc.size + size, acc.files + 1) yield from d.values()
def main(directory): total_files, extensions = 0, set() for accumulated in accumulate_size_by_extension(get_files_info(directory)): total_files += accumulated.files extensions |= {accumulated} for (ext, size, files) in sorted(extensions, key=lambda acc: acc.files, reverse=True): yield render_row(ext, size, get_his(files, total_files))