Closes #167.
Signed-off-by: Richard Marko <rmarko(a)redhat.com>
---
pyfaf/bugzilla.py | 4 ++++
pyfaf/kb.py | 25 +++++++++++++++++++++++++
2 files changed, 29 insertions(+)
diff --git a/pyfaf/bugzilla.py b/pyfaf/bugzilla.py
index e7b4503..16945e1 100644
--- a/pyfaf/bugzilla.py
+++ b/pyfaf/bugzilla.py
@@ -718,6 +718,10 @@ class Bugzilla(object):
logging.warning('Refusing to process report with no backtrace.')
continue
+ if pyfaf.kb.report_in_kb(self.db, report):
+ logging.info('Report matches knowledge base entry, skipping.')
+ continue
+
if report.packages:
data['package'] = report.packages[0].installed_package
if report.reasons:
diff --git a/pyfaf/kb.py b/pyfaf/kb.py
index 840f02e..82d7a97 100644
--- a/pyfaf/kb.py
+++ b/pyfaf/kb.py
@@ -37,3 +37,28 @@ def get_kb_pkgname_parsers(db, opsys_id=None):
result[parser] = kbentry.solution
return result
+
+
+def report_in_kb(db, report):
+ '''
+ Check if `report` matches entry in knowledge base.
+ '''
+
+ if report.backtraces:
+ bt = report.backtraces[0]
+ parsers = get_kb_btpath_parsers(db)
+
+ for parser in parsers:
+ for frame in bt.frames:
+ if parser.match(frame.symbolsource.path):
+ return True
+
+ if report.packages:
+ parsers = get_kb_pkgname_parsers(db)
+
+ for parser in parsers:
+ for package in report.packages:
+ if parser.match(package.installed_package.nvra()):
+ return True
+
+ return False
--
1.8.1.4