+ except AttributeError as err:
+ logging.error(repr(err))
+ return None
+ except SyntaxError as err:
+ logging.error(
+ f"The filter {cond} is not correct. Check if all tags are "
+ f"enclosed by apostrophes.\n{repr(err)}"
+ )
+ return None
+
+ def filter_tests_by_name(self, element, params=None, data_set=u"tests",
+ continue_on_error=False):
+ """Filter required data from the given jobs and builds.
+
+ The output data structure is:
+
+ - job 1
+ - build 1
+ - test (or suite) 1 ID:
+ - param 1
+ - param 2
+ ...
+ - param n
+ ...
+ - test (or suite) n ID:
+ ...
+ ...
+ - build n
+ ...
+ - job n
+
+ :param element: Element which will use the filtered data.
+ :param params: Parameters which will be included in the output. If None,
+ all parameters are included.
+ :param data_set: The set of data to be filtered: tests, suites,
+ metadata.
+ :param continue_on_error: Continue if there is error while reading the
+ data. The Item will be empty then
+ :type element: pandas.Series
+ :type params: list
+ :type data_set: str
+ :type continue_on_error: bool
+ :returns: Filtered data.
+ :rtype pandas.Series
+ """
+
+ include = element.get(u"include", None)
+ if not include:
+ logging.warning(u"No tests to include, skipping the element.")
+ return None
+
+ if params is None:
+ params = element.get(u"parameters", None)
+ if params:
+ params.append(u"type")
+
+ data = pd.Series()
+ try:
+ for job, builds in element[u"data"].items():
+ data[job] = pd.Series()
+ for build in builds:
+ data[job][str(build)] = pd.Series()
+ for test in include:
+ try:
+ reg_ex = re.compile(str(test).lower())
+ for test_id in self.data[job][
+ str(build)][data_set].keys():
+ if re.match(reg_ex, str(test_id).lower()):
+ test_data = self.data[job][
+ str(build)][data_set][test_id]
+ data[job][str(build)][test_id] = pd.Series()
+ if params is None:
+ for param, val in test_data.items():
+ data[job][str(build)][test_id]\
+ [param] = val
+ else:
+ for param in params:
+ try:
+ data[job][str(build)][
+ test_id][param] = \
+ test_data[param]
+ except KeyError:
+ data[job][str(build)][
+ test_id][param] = u"No Data"
+ except KeyError as err:
+ logging.error(repr(err))
+ if continue_on_error:
+ continue
+ return None
+ return data
+
+ except (KeyError, IndexError, ValueError) as err:
+ logging.error(
+ f"Missing mandatory parameter in the element "
+ f"specification: {repr(err)}"
+ )