コード例 #1
0
ファイル: parsers.py プロジェクト: hzlf/openbroadcast
     def parse(self, stream):
         """
         Returns a 2-tuple of `(data, files)`.
 
         `data` will be an object which is the parsed content of the response.
         `files` will always be `None`.
         """
         try:
             return (yaml.safe_load(stream), None)
         except ValueError, exc:
             raise ErrorResponse(status.HTTP_400_BAD_REQUEST, {"detail": "YAML parse error - %s" % unicode(exc)})
コード例 #2
0
        def parse(self, stream):
            """
            Returns a 2-tuple of `(data, files)`.

            `data` will be an object which is the parsed content of the response.
            `files` will always be `None`.
            """
            try:
                return (yaml.safe_load(stream), None)
            except ValueError, exc:
                raise ErrorResponse(status.HTTP_400_BAD_REQUEST,
                                    {'detail': 'YAML parse error - %s' % unicode(exc)})
コード例 #3
0
    def parse(self, stream):
        """
        Returns a 2-tuple of `(data, files)`.

        `data` will be an object which is the parsed content of the response.
        `files` will always be `None`.
        """
        try:
            return (yaml.safe_load(stream), None)
        except (ValueError, yaml.parser.ParserError) as exc:
            content = {'detail': 'YAML parse error - %s' % str(exc)}
            raise ErrorResponse(status.HTTP_400_BAD_REQUEST, content)