Debian Codegraph @

toolbin/tests/revert_baseline

raw
1 #!/usr/bin/env python
2 # -*- Mode: python -*-
3
4 # Copyright (C) 2001-2023 Artifex Software, Inc.
5 # All Rights Reserved.
6 #
7 # This software is provided AS-IS with no warranty, either express or
8 # implied.
9 #
10 # This software is distributed under license and may not be copied,
11 # modified or distributed except as expressly authorized under the terms
12 # of the license contained in the file LICENSE in this distribution.
13 #
14 # Refer to licensing information at http://www.artifex.com or contact
15 # Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
16 # CA 94129, USA, for further information.
17 #
18
19
20 #
21 # revert_baseline <file>
22 #
23 # this script updates the testdata database with a new baseline sum
24 # for all versions of file <file>. use this when you've accidentally
25 # updated a baseline you shouldn't have.
26
27 import gstestgs
28 import gsconf
29 import gssum
30 import gsparamsets
31 import rasterdb
32 import anydbm
33 import time
34 import os, sys
35 import string
36 import gsutil
37
38 def make_entry(ifile, device, dpi, band):
39 ofile = "%s.%s.%d.%d" % (ifile, device, dpi, band)
40 print "reverting entry: " + ofile + "...",
41 sys.stdout.flush()
42
43 gs = gstestgs.Ghostscript()
44 gs.command = gsconf.baselinegs
45 gs.infile = gsconf.comparefiledir + ifile
46 gs.outfile = ofile
47 gs.device = device
48 gs.dpi = dpi
49 gs.band = band
50
51 if gs.process():
52 try:
53 if gsconf.log_baseline:
54 log = open(gsconf.log_baseline, "a")
55 log.write(time.ctime() + " " + ifile + " reverted\n")
56 log.close()
57 gssum.add_file(ofile)
58 rasterdb.put_file(ofile)
59 os.unlink(ofile)
60 print "done."
61 except OSError:
62 print "no output produced."
63 else:
64 print "error."
65
66
67 f = os.path.basename(sys.argv[1])
68
69 if gsutil.check_extension(f):
70 for params in gsparamsets.testparamsets:
71 make_entry(f, params.device, params.resolution, params.banding)