def get_filter(org_name, def_id, filter_name=None, filter_id=None): filter_api = FilterAPI() filters = filter_api.filters_by_cvd_and_org(def_id, org_name) if filter_name: filters = [f for f in filters if f["name"] == filter_name] if filter_id: filters = [f for f in filters if f["id"] == filter_id] if len(filters) < 1: raise ApiDataError(_("Could not find filter [ %s ].") % (filter_name or filter_id)) else: # there can only be one filter matching name in a def return filters[0]
def get_filter(org_name, def_id, filter_name=None, filter_id=None): filter_api = FilterAPI() filters = filter_api.filters_by_cvd_and_org(def_id, org_name) if filter_name: filters = [f for f in filters if f["name"] == filter_name] if filter_id: filters = [f for f in filters if f["id"] == filter_id] if len(filters) < 1: raise ApiDataError( _("Could not find filter [ %s ].") % (filter_name or filter_id)) else: # there can only be one filter matching name in a def return filters[0]
def __init__(self): super(FilterAction, self).__init__() self.api = FilterAPI()
def get_filter(org_name, name): filter_api = FilterAPI() filter = filter_api.info(org_name, name) if filter == None: print _("Cannot find filter [ %s ]") % (name) return filter
def get_filter(org_name, name): filter_api = FilterAPI() filter = filter_api.info(org_name, name) if filter == None: raise ApiDataError(_("Cannot find filter [ %s ]") % (name)) return filter
def get_filter(org_name, name): filter_api = FilterAPI() my_filter = filter_api.info(org_name, name) if my_filter == None: raise ApiDataError(_("Cannot find filter [ %s ]") % (name)) return my_filter