def apply(self, working_list, act_on): """ Apply filters to a working list of indices/snapshots and return resulting list. """ self.act_on = act_on result_list = self._apply_closed_timerange(working_list) if self.all_items: logger.info( 'Matching all %s. Ignoring parameters other than exclude.', self.act_on) # Closed time range couldn't be applied if result_list is None: result_list = working_list # Apply filters one by one (if any) from the list. for f in self.built_list: is_timebased = f.get('method', None) in ('newer_than', 'older_than') # Don't apply timebased filters for a closed time range. if self.closed_timerange and is_timebased: continue # When all items are seleted ignore filters other than exclude if self.all_items and 'exclude' not in f: continue logger.debug('Applying filter: %s', f) result_list = apply_filter(result_list, **f) return result_list
def apply(self, working_list, act_on): """ Apply filters to a working list of indices/snapshots and return resulting list. """ self.act_on = act_on result_list = self._apply_closed_timerange(working_list) if self.all_items: logger.info('Matching all %s. Ignoring parameters other than exclude.', self.act_on) # Closed time range couldn't be applied if result_list is None: result_list = working_list # Apply filters one by one (if any) from the list. for f in self.built_list: is_timebased = f.get('method', None) in ('newer_than', 'older_than') # Don't apply timebased filters for a closed time range. if self.closed_timerange and is_timebased: continue # When all items are seleted ignore filters other than exclude if self.all_items and 'exclude' not in f: continue logger.debug('Applying filter: %s', f) result_list = apply_filter(result_list, **f) return result_list
def _apply_closed_timerange(self, working_list): """ Apply separated filtering for a closed time range. In case filtering is not applied None is returned. """ if self.closed_timerange: newer_than, older_than = self.get_timebased() if newer_than['value'] < older_than['value']: print 'ERROR: Wrong time period newer_than parameter must be > older_than.' sys.exit(1) if not self.all_items: # We don't apply time range filtering in case of all_* options. logger.debug('Applying time range filters, result will be intersection\n' 'newer_than: %s\nolder_than: %s', newer_than, older_than) newer_range = set(apply_filter(working_list, **newer_than)) older_range = set(apply_filter(working_list, **older_than)) result_list = list(newer_range & older_range) return result_list
def _apply_closed_timerange(self, working_list): """ Apply separated filtering for a closed time range. In case filtering is not applied None is returned. """ if self.closed_timerange: newer_than, older_than = self.get_timebased() if newer_than['value'] < older_than['value']: print 'ERROR: Wrong time period newer_than parameter must be > older_than.' sys.exit(1) if not self.all_items: # We don't apply time range filtering in case of all_* options. logger.debug( 'Applying time range filters, result will be intersection\n' 'newer_than: %s\nolder_than: %s', newer_than, older_than) newer_range = set(apply_filter(working_list, **newer_than)) older_range = set(apply_filter(working_list, **older_than)) result_list = list(newer_range & older_range) return result_list