示例#1
0
文件: sample.py 项目: TheDr1ver/crits
    def _json_yaml_convert(self, exclude=[]):
        """
        Helper to convert to a dict before converting to JSON.

        :param exclude: list of fields to exclude.
        :type exclude: list
        :returns: json
        """

        d = self.to_dict(exclude)
        if 'filedata' not in exclude:
            (d['filedata'], ext) = format_file(self.filedata.read(), 'base64')
        return json.dumps(d, default=json_handler)
示例#2
0
文件: sample.py 项目: s4l3h1/crits
    def _json_yaml_convert(self, exclude=[]):
        """
        Helper to convert to a dict before converting to JSON.

        :param exclude: list of fields to exclude.
        :type exclude: list
        :returns: json
        """

        d = self.to_dict(exclude)
        if 'filedata' not in exclude:
            (d['filedata'], ext) = format_file(self.filedata.read(), 'base64')
        return json.dumps(d, default=json_handler)
示例#3
0
文件: api.py 项目: thelok/crits-1
    def _format_data(self, filedata, file_format=None):
        """
        Format filedata based on request.

        :param filedata: The filedata to format.
        :type filedata: str
        :param file_format: The format the file should be in:
                            "base64", "zlib", "raw", "invert".
        :type file_format: str
        :returns: list of [<formatted data>, <file extension>]
        """

        if file_format not in ('base64', 'zlib', 'raw', 'invert'):
            file_format = 'raw'
        return format_file(filedata, file_format)[0]
示例#4
0
    def _format_data(self, filedata, file_format=None):
        """
        Format filedata based on request.

        :param filedata: The filedata to format.
        :type filedata: str
        :param file_format: The format the file should be in:
                            "base64", "zlib", "raw", "invert".
        :type file_format: str
        :returns: list of [<formatted data>, <file extension>]
        """

        if file_format not in ('base64', 'zlib', 'raw', 'invert'):
            file_format = 'raw'
        return format_file(filedata, file_format)[0]