1#! /usr/bin/env python
2
3# Copyright 2018 Google LLC.
4# Use of this source code is governed by a BSD-style license that can be
5# found in the LICENSE file.
6
7import csv
8import os
9import shutil
10import sys
11
12def gset(path):
13    s = set()
14    if os.path.isfile(path):
15        with open(path, 'r') as f:
16            for line in f:
17                s.add(line.strip())
18    return s
19
20def main():
21    assert '/' in [os.sep, os.altsep]
22    assets = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir,
23                          'platform_tools/android/apps/skqp/src/main/assets')
24    models = gset(assets + '/gmkb/models.txt')
25    good = gset('good.txt')
26    bad = gset('bad.txt')
27    assert good.isdisjoint(bad)
28    do_score = good & models
29    no_score = bad | (good - models)
30    to_delete = models & bad
31    for d in to_delete:
32        path = assets + '/gmkb/' + d
33        if os.path.isdir(path):
34            shutil.rmtree(path)
35    results = dict()
36    for n in do_score:
37        results[n] = 0
38    for n in no_score:
39        results[n] = -1
40    skqp =  assets + '/skqp'
41    if not os.path.isdir(skqp):
42        os.mkdir(skqp)
43    with open(skqp + '/rendertests.txt', 'w') as o:
44        for n in sorted(results):
45            o.write('%s,%d\n' % (n, results[n]))
46
47if __name__ == '__main__':
48    main()
49
50