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
评论列表
文章目录