()
| 192 | |
| 193 | |
| 194 | def main(): |
| 195 | ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0]) |
| 196 | ap.add_argument("--needs-graph", action="store_true") |
| 197 | ap.add_argument("--root") |
| 198 | ap.add_argument("--changed", required=True) |
| 199 | ap.add_argument("--selection") |
| 200 | ap.add_argument("--detect") |
| 201 | ap.add_argument("--depth", type=int, default=15) |
| 202 | ap.add_argument("--meta", default="{}") |
| 203 | ap.add_argument("--out") |
| 204 | ap.add_argument("--summary") |
| 205 | a = ap.parse_args() |
| 206 | with open(a.changed, encoding="utf-8") as fh: |
| 207 | changed = sorted({line.strip() for line in fh if line.strip()}) |
| 208 | if a.needs_graph: |
| 209 | print("yes" if needs_graph(changed) else "no") |
| 210 | return 0 |
| 211 | if not (a.root and a.selection and a.out): |
| 212 | ap.error("--root, --selection and --out are required") |
| 213 | with open(a.selection, encoding="utf-8") as fh: |
| 214 | selection = json.load(fh) |
| 215 | detect = None |
| 216 | if a.detect: |
| 217 | with open(a.detect, encoding="utf-8") as fh: |
| 218 | detect = json.load(fh) |
| 219 | result = predict(a.root, changed, selection, detect, a.depth) |
| 220 | meta = json.loads(a.meta) |
| 221 | result["meta"] = meta |
| 222 | with open(a.out, "w", encoding="utf-8") as fh: |
| 223 | json.dump(result, fh, indent=1, sort_keys=True) |
| 224 | fh.write("\n") |
| 225 | if a.summary: |
| 226 | with open(a.summary, "w", encoding="utf-8") as fh: |
| 227 | fh.write(summary(result, meta)) |
| 228 | return 0 |
| 229 | |
| 230 | |
| 231 | if __name__ == "__main__": |
no test coverage detected