def _execute(self, rule, data, reports, default_location): try: result = pyflwor.execute(rule.query, data) except SyntaxError as e: self.log.error("SyntaxError on query %s: %s", rule.id, e) else: # result can be of types: # - pyflwor.OrderedSet.OrderedSet<object> for Path queries # - tuple<object> for FLWR queries single return # - tuple<tuple<object>> for FLWR queries multi return # - tuple<dict<str, object>> for FLWR queries named return # NOTE: sometimes 'object' can be a tuple or dict... self.log.info("Query %s found %d matches.", rule.id, len(result)) for match in result: self.log.debug("Query %s found %s", rule.id, match) self._report(rule, match, reports, default_location)
def __init__(self, sprint, real_bugs, allowed_colors=None): # we have to copy bugs, because each section is removing their bugs # from the list self._resolve_blocked_and_dependson(real_bugs) self.bugs = real_bugs[:] bugs = real_bugs[:] self._sprint = sprint self._board_schema = sprint.get_board() namespace = self.create_base_namespace() for color in self._board_schema['colors']: namespace['bugs'] = self.bugs query_colors = self.TMPL_COLORS % color['cond'].strip() try: colored_bug = pyflwor.execute(query_colors, namespace) except PyFlworException as e: flash(str(e)) colored_bug = [] for cbug in colored_bug: cbug.scrum.color = color['color'] self.bugs.remove(cbug) if allowed_colors: bugs = [ bug for bug in bugs if bug.scrum.color in allowed_colors ] self.columns = [ Column(column, bugs) for column in reversed(self._board_schema['board']) ] self.columns = list(reversed(self.columns))
def __init__(self, section, bugs): self.name = section['name'] namespace = Board.create_base_namespace() namespace['bugs'] = bugs condition = section['cond'].strip() if condition: query = self.TMPL % section['cond'] try: self.bugs = pyflwor.execute(query, namespace) except PyflworSyntaxError as e: flash("Syntax error in query: %s" % section['cond']) self.bugs = [] except KeyError as e: msg = "Unexpected token %s in query: '%s'" % ( e, section['cond'], ) flash(msg) self.bugs = [] except PyFlworException as e: flash(str(e)) self.bugs = [] except Exception as e: err = "Problem with query %s, namespace %s" % (query, namespace) EXCEPTION(err) self.bugs = [] else: # no condition == all bugs self.bugs = bugs[:] #those bugs that was taken should be removed from global bug list for bug in self.bugs: bugs.remove(bug)