def policy_list_atoms(self, operator, filter): """Return a list of atoms that match the given filters.""" # This method is available for everyone atom = Atom(self.db) filters = self._parse_filters(filter, { 'name': None, 'date': self._parse_create_date_range, 'create': self._parse_create_date_range, 'desc': None, 'foundation': None, }, default_filter='name', default_value=None) date_start = date_end = None if filters['date']: date_start, date_end = filters['date'] if date_end is NotSet: # only the specific date should be used date_end = date_start create_start = create_end = None if filters['create']: create_start, create_end = filters['create'] if create_end is NotSet: # only the specific date should be used create_end = create_start ret = [] for row in atom.search(name=filters['name'], description=filters['desc'], create_start=create_start, create_end=create_end, foundation_start=date_start, foundation_end=date_end, foundation=filters['foundation']): ret.append({'name': row['name'], 'desc': row['description']}) return sorted(ret, key=lambda r: r['name'])
def policy_list_atoms(self, operator, filter): """Return a list of atoms that match the given filters.""" # This method is available for everyone atom = Atom(self.db) filters = self._parse_filters(filter, {'name': None, 'date': self._parse_create_date_range, 'create': self._parse_create_date_range, 'desc': None, 'foundation': None}, default_filter='name', default_value=None) date_start = date_end = None if filters['date']: date_start, date_end = filters['date'] if date_end is NotSet: # only the specific date should be used date_end = date_start create_start = create_end = None if filters['create']: create_start, create_end = filters['create'] if create_end is NotSet: # only the specific date should be used create_end = create_start ret = [] for row in atom.search(name=filters['name'], description=filters['desc'], create_start=create_start, create_end=create_end, foundation_start=date_start, foundation_end=date_end, foundation=filters['foundation']): ret.append({ 'name': row['name'], 'desc': row['description'], }) return sorted(ret, key=lambda r: r['name'])
def process_atoms(stream): """Go through all atoms in the database and send them to the stream.""" logger.info('process_atoms started') db = Factory.get('Database')() atom = Atom(db) for row in atom.search(): stream.write(';'.join( (row['name'], row['description'], row['foundation'] or '', row['created_at'].strftime('%Y-%m-%d')))) stream.write('\n') logger.info('process_atoms done')
def process_atoms(stream): """Go through all atoms in the database and send them to the stream.""" logger.info('process_atoms started') db = Factory.get('Database')() atom = Atom(db) for row in atom.search(): stream.write(';'.join((row['name'], row['description'], row['foundation'] or '', row['created_at'].strftime('%Y-%m-%d')))) stream.write('\n') logger.info('process_atoms done')