blob: a1c3171de11413d08fccd51d9b15fa64c865f208 [file] [log] [blame]
Tom Sepez30762ce2015-04-09 13:37:02 -07001#!/usr/bin/env python
2# Copyright 2015 The PDFium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6import os
7
8import common
9
10class Suppressor:
Tom Sepez5c1efd42016-01-19 15:05:36 -080011 def __init__(self, finder, feature_string):
12 feature_vector = feature_string.strip().split(",")
13 v8_option = ["nov8", "v8"]["V8" in feature_vector]
14 xfa_option = ["noxfa", "xfa"]["XFA" in feature_vector]
Tom Sepezacfe9a72016-01-19 11:28:59 -080015 with open(os.path.join(finder.TestingDir(), 'SUPPRESSIONS')) as f:
16 self.suppression_set = set(self._FilterSuppressions(
Tom Sepez5c1efd42016-01-19 15:05:36 -080017 common.os_name(), v8_option, xfa_option, self._ExtractSuppressions(f)))
Tom Sepez30762ce2015-04-09 13:37:02 -070018
Tom Sepezacfe9a72016-01-19 11:28:59 -080019 def _ExtractSuppressions(self, f):
20 return [y.split(' ') for y in
21 [x.split('#')[0].strip() for x in
22 f.readlines()] if y]
23
24 def _FilterSuppressions(self, os, js, xfa, unfiltered_list):
25 return [x[0] for x in unfiltered_list
26 if self._MatchSuppression(x, os, js, xfa)]
27
28 def _MatchSuppression(self, item, os, js, xfa):
29 os_column = item[1].split(",");
30 js_column = item[2].split(",");
31 xfa_column = item[3].split(",");
32 return (('*' in os_column or os in os_column) and
33 ('*' in js_column or js in js_column) and
34 ('*' in xfa_column or xfa in xfa_column))
Tom Sepez30762ce2015-04-09 13:37:02 -070035
36 def IsSuppressed(self, input_filename):
Tom Sepezacfe9a72016-01-19 11:28:59 -080037 if input_filename in self.suppression_set:
38 print "%s is suppressed" % input_filename
Tom Sepez30762ce2015-04-09 13:37:02 -070039 return True
40 return False