_to_disk.py 文件源码

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

项目:deb-subunit 作者: openstack 项目源码 文件源码
def to_disk(argv=None, stdin=None, stdout=None):
    if stdout is None:
        stdout = sys.stdout
    if stdin is None:
        stdin = sys.stdin
    parser = optparse.OptionParser(
        description="Export a subunit stream to files on disk.",
        epilog=dedent("""\
            Creates a directory per test id, a JSON file with test
            metadata within that directory, and each attachment
            is written to their name relative to that directory.

            Global packages (no test id) are discarded.

            Exits 0 if the export was completed, or non-zero otherwise.
            """))
    parser.add_option(
        "-d", "--directory", help="Root directory to export to.",
        default=".")
    options, args = parser.parse_args(argv)
    if len(args) > 1:
        raise Exception("Unexpected arguments.")
    if len(args):
        source = io.open(args[0], 'rb')
    else:
        source = stdin
    exporter = DiskExporter(options.directory)
    result = StreamToDict(exporter.export)
    run_tests_from_stream(source, result, protocol_version=2)
    return 0
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号