
this handles the piece of work we've been talking about for a while in moving the queries.yaml file into a directory with a bunch of files. These remain yaml so that they can be tagged with additional metadata. This would support the concept of soft deleting as well as other useful meta data to gauge our evolution of the bugs we track over time. This should see some real review as it's extensive enough of a change that the existing tests might not be sufficient. However it should be enough to move this forward quite a bit. This also makes future looking statements about doing soft deletes with a resolved_at keyword in the future. That implementation will come later. Change-Id: I86317fcf6f1886ab5b6c0ee154b29e71865c52b7
35 lines
1.1 KiB
Python
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
|