$37 GRAYBYTE WORDPRESS FILE MANAGER $11

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/alt/python37/lib/python3.7/site-packages/raven/utils/

HOME
Current File : /opt/alt/python37/lib/python3.7/site-packages/raven/utils//json.py
"""
raven.utils.json
~~~~~~~~~~~~~~~~~~~~~~~~

:copyright: (c) 2010-2012 by the Sentry Team, see AUTHORS for more details.
:license: BSD, see LICENSE for more details.
"""

from __future__ import absolute_import

import codecs
import datetime
import uuid
import json

try:
    JSONDecodeError = json.JSONDecodeError
except AttributeError:
    JSONDecodeError = ValueError


class BetterJSONEncoder(json.JSONEncoder):
    ENCODER_BY_TYPE = {
        uuid.UUID: lambda o: o.hex,
        datetime.datetime: lambda o: o.strftime('%Y-%m-%dT%H:%M:%SZ'),
        set: list,
        frozenset: list,
        bytes: lambda o: o.decode('utf-8', errors='replace')
    }

    def default(self, obj):
        try:
            encoder = self.ENCODER_BY_TYPE[type(obj)]
        except KeyError:
            try:
                return super(BetterJSONEncoder, self).default(obj)
            except TypeError:
                return repr(obj)
        return encoder(obj)


def better_decoder(data):
    return data


def dumps(value, **kwargs):
    try:
        return json.dumps(value, cls=BetterJSONEncoder, **kwargs)
    except Exception:
        kwargs['encoding'] = 'safe-utf-8'
        return json.dumps(value, cls=BetterJSONEncoder, **kwargs)


def loads(value, **kwargs):
    return json.loads(value, object_hook=better_decoder)


_utf8_encoder = codecs.getencoder('utf-8')


def safe_encode(input, errors='backslashreplace'):
    return _utf8_encoder(input, errors)


_utf8_decoder = codecs.getdecoder('utf-8')


def safe_decode(input, errors='replace'):
    return _utf8_decoder(input, errors)


class Codec(codecs.Codec):

    def encode(self, input, errors='backslashreplace'):
        return safe_encode(input, errors)

    def decode(self, input, errors='replace'):
        return safe_decode(input, errors)


class IncrementalEncoder(codecs.IncrementalEncoder):
    def encode(self, input, final=False):
        return safe_encode(input, self.errors)[0]


class IncrementalDecoder(codecs.IncrementalDecoder):
    def decode(self, input, final=False):
        return safe_decode(input, self.errors)[0]


class StreamWriter(Codec, codecs.StreamWriter):
    pass


class StreamReader(Codec, codecs.StreamReader):
    pass


def getregentry(name):
    if name != 'safe-utf-8':
        return None
    return codecs.CodecInfo(
        name='safe-utf-8',
        encode=safe_encode,
        decode=safe_decode,
        incrementalencoder=IncrementalEncoder,
        incrementaldecoder=IncrementalDecoder,
        streamreader=StreamReader,
        streamwriter=StreamWriter,
    )


codecs.register(getregentry)

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
31 Aug 2024 6.49 AM
root / 996
0755
__pycache__
--
31 Aug 2024 6.49 AM
root / 996
0755
serializer
--
31 Aug 2024 6.49 AM
root / 996
0755
__init__.py
4.709 KB
30 Oct 2017 12.41 AM
root / 996
0644
compat.py
5.543 KB
30 Oct 2017 12.41 AM
root / 996
0644
conf.py
2.225 KB
30 Oct 2017 12.41 AM
root / 996
0644
encoding.py
3.226 KB
30 Oct 2017 12.41 AM
root / 996
0644
http.py
1.953 KB
30 Oct 2017 12.41 AM
root / 996
0644
imports.py
0.395 KB
30 Oct 2017 12.41 AM
root / 996
0644
json.py
2.544 KB
30 Oct 2017 12.41 AM
root / 996
0644
ssl_match_hostname.py
3.514 KB
30 Oct 2017 12.41 AM
root / 996
0644
stacks.py
9.806 KB
30 Oct 2017 12.41 AM
root / 996
0644
testutils.py
0.681 KB
30 Oct 2017 12.41 AM
root / 996
0644
transaction.py
1.063 KB
30 Oct 2017 12.41 AM
root / 996
0644
urlparse.py
0.465 KB
30 Oct 2017 12.41 AM
root / 996
0644
wsgi.py
3.644 KB
30 Oct 2017 12.41 AM
root / 996
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF