예제 #1
0
    def get(self, req, lookup):
        formatters = get_all_formatters()

        if req.args.get('criteria'):
            formatters = (f for f in formatters if getattr(f, req.args.get('criteria')) is True)

        return ListCursor([{'name': type(f).__name__} for f in formatters])
예제 #2
0
    def get(self, req, lookup):
        formatters = get_all_formatters()

        if req.args.get('criteria'):
            formatters = (f for f in formatters if getattr(f, req.args.get('criteria')) is True)

        return ListCursor([{'name': type(f).__name__} for f in formatters])
예제 #3
0
    def _validate_and_get_formatter(self, doc):
        """Validates incoming request and gets the formatter to be used"""
        if doc.get('item_ids') == 0:
            raise SuperdeskApiError.badRequestError('No items to export.')

        formatter_name = doc.get('format_type')
        formatter = next((f for f in get_all_formatters() if type(f).__name__ == formatter_name), None)
        if not formatter:
            raise SuperdeskApiError.badRequestError('Formatter not found for requested format type.')

        return formatter
예제 #4
0
 def _get_formatter(self, name):
     formatters = get_all_formatters()
     return next((f for f in formatters if type(f).__name__ == name), None)
예제 #5
0
 def _get_formatter(self, name):
     formatters = get_all_formatters()
     return next((f for f in formatters if type(f).__name__ == name), None)
예제 #6
0
 def get(self, req, lookup):
     formatters = get_all_formatters()
     return ListCursor([{'name': type(f).__name__} for f in formatters])