elastic-recheck/elastic_recheck/loader.py
Clark Boylan 8b2e067b8c Revert "move to static LOG"
This reverts commit e75b996e60.

Change is being reverted because we can't actually use a static LOG
object if we expect setup_logging to do the right thing at runtime.
Python logging will load logging objects at import time using the static
LOG object before setup_logging can run otherwise.

Conflicts:
	elastic_recheck/bot.py
	elastic_recheck/elasticRecheck.py

Change-Id: I582c7e9c9b3c2ccab6a695bfba00a61f7c0a04a9
2014-03-06 11:12:43 -08:00

35 lines
1.1 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 os.path
import yaml
def load(directory='queries'):
"""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
data.append(query)
return data