def command(self): session, config = self.session, self.session.config if len(self.args) < 1: raise UsageError('Delete what?') removed = 0 filters = config.get('filter', {}) filter_terms = config.get('filter_terms', {}) args = list(self.args) for fid in self.args: if fid not in filters: match = [f for f in filters if filter_terms[f] == fid] if match: args.remove(fid) args.extend(match) for fid in args: if (config.parse_unset(session, 'filter:%s' % fid) and config.parse_unset(session, 'filter_tags:%s' % fid) and config.parse_unset(session, 'filter_terms:%s' % fid)): removed += 1 else: session.ui.warning('Failed to remove %s' % fid) if removed: self.finish() return True
def command(self): session, config = self.session, self.session.config existing = [v.lower() for v in config.get('tag', {}).values()] clean_session = mailpile.ui.Session(config) clean_session.ui = session.ui result = [] for tag in self.args: tag_id = config.get_tag_id(tag) if tag_id: # FIXME: Update filters too if (Search(clean_session, arg=['tag:%s' % tag]).run() and Tag(clean_session, arg=['-%s' % tag, 'all']).run() and config.parse_unset(session, 'tag:%s' % tag_id)): result.append({'name': tag, 'tid': tag_id}) else: raise Exception('That failed, not sure why?!') else: self._error('No such tag %s' % tag) if result: config.save() return {'removed': result}