Commits (2)
#!/usr/bin/env python3
#
# Copyright © 2020-2021 Chris Lamb <lamby@debian.org>
#
# diffoscope is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# diffoscope is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with diffoscope. If not, see <https://www.gnu.org/licenses/>.
import re
import sys
import json
import click
import fileinput
@click.command()
def main():
"""
Takes the output from `diffoscope --json=X` and attempts to guess which
issue(s) the package is affected by. For example:
$ diffoscope --json=output.json a.dsc b.dsc
$ bin/auto-classify output.json
build_path_captured_by_octave
$
If no arguments are provided, the JSON is read from standard input so
you can pipe it in. For example:
$ diffoscope --json=- a.dsc b.dsc | bin/auto-classify
build_path_captured_by_octave
"""
raw = "".join(fileinput.input())
for x in walk_json(json.loads(raw)):
print(x)
def walk_json(elem):
if isinstance(elem, list):
for x in elem:
......@@ -121,7 +162,4 @@ def walk_json(elem):
if __name__ == "__main__":
raw = "".join(fileinput.input())
for x in walk_json(json.loads(raw)):
print(x)
sys.exit(main())