from lib.fmd.namedentity import NamedEntity
from lib.fmd.decorators import Action, ListStage, GetStage
from lib.exceptions.workflow import EntryException

@Action(ListStage.DATAGATHERING)
def list_records(context, output):
    output = []

    if hasattr(context, 'filter'):
        context.log.debug('Using filter [%s]' % context.filter)
        entries = context.ddb.list(context.filter)
    else:
        entries = context.ddb.list()

    return NamedEntity('records', entries)

[((5, 1, 5, 32), 'lib.fmd.decorators.Action', 'Action', ({(5, 8, 5, 31): 'ListStage.DATAGATHERING'}, {}), '(ListStage.DATAGATHERING)', False, 'from lib.fmd.decorators import Action, ListStage, GetStage\n'), ((15, 11, 15, 42), 'lib.fmd.namedentity.NamedEntity', 'NamedEntity', ({(15, 23, 15, 32): '"""records"""', (15, 34, 15, 41): 'entries'}, {}), "('records', entries)", False, 'from lib.fmd.namedentity import NamedEntity\n')]