elastic-recheck/elastic_recheck/loader.py
Joe Gordon 48c674701d Stop logging skipped bugs
As we continue to use  elastic-recheck the number of skipped bugs will
continue to grow, and we reload bugs every time we attempt to classify a
bug so the logs get spammed with fairly useless comments about skipping
bugs.

Change-Id: I35bda3326379a77d1048f11cfd80ba8af8d05eaa
2014-01-23 16:30:10 -08:00

39 lines
1.2 KiB
Python

# Copyright Samsung Electronics 2013. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
"""Loader for elastic search queries.
A set of utility methods to load queries for elastic recheck.
"""
import glob
import logging
import os.path
import yaml
LOG = logging.getLogger('recheckwatchbot')
def load(directory='queries', skip_resolved=True):
"""Load queries from a set of yaml files in a directory."""
bugs = glob.glob("%s/*.yaml" % directory)
data = []
for fname in bugs:
bugnum = os.path.basename(fname).rstrip('.yaml')
query = yaml.load(open(fname).read())
query['bug'] = bugnum
if not (skip_resolved and 'resolved_at' in query):
data.append(query)
return data