aboutsummaryrefslogtreecommitdiffstats
path: root/python/itsdangerous/url_safe.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-09-06 16:31:13 -0700
committerJames Taylor <user234683@users.noreply.github.com>2019-09-06 16:31:13 -0700
commit3d57e14df7ba5f14a634295caf3b2e60da50bfe2 (patch)
tree4903bcb79a49ad714a1a9129765b9545405c9978 /python/itsdangerous/url_safe.py
parentac32b24b2a011292b704a3f27e8fd08a7ae9424b (diff)
downloadyt-local-3d57e14df7ba5f14a634295caf3b2e60da50bfe2.tar.lz
yt-local-3d57e14df7ba5f14a634295caf3b2e60da50bfe2.tar.xz
yt-local-3d57e14df7ba5f14a634295caf3b2e60da50bfe2.zip
Remove windows python distribution from repo and add requirements.txt
Diffstat (limited to 'python/itsdangerous/url_safe.py')
-rw-r--r--python/itsdangerous/url_safe.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/python/itsdangerous/url_safe.py b/python/itsdangerous/url_safe.py
deleted file mode 100644
index fcaa011..0000000
--- a/python/itsdangerous/url_safe.py
+++ /dev/null
@@ -1,65 +0,0 @@
-import zlib
-
-from ._json import _CompactJSON
-from .encoding import base64_decode
-from .encoding import base64_encode
-from .exc import BadPayload
-from .serializer import Serializer
-from .timed import TimedSerializer
-
-
-class URLSafeSerializerMixin(object):
- """Mixed in with a regular serializer it will attempt to zlib
- compress the string to make it shorter if necessary. It will also
- base64 encode the string so that it can safely be placed in a URL.
- """
-
- default_serializer = _CompactJSON
-
- def load_payload(self, payload, *args, **kwargs):
- decompress = False
- if payload.startswith(b"."):
- payload = payload[1:]
- decompress = True
- try:
- json = base64_decode(payload)
- except Exception as e:
- raise BadPayload(
- "Could not base64 decode the payload because of an exception",
- original_error=e,
- )
- if decompress:
- try:
- json = zlib.decompress(json)
- except Exception as e:
- raise BadPayload(
- "Could not zlib decompress the payload before decoding the payload",
- original_error=e,
- )
- return super(URLSafeSerializerMixin, self).load_payload(json, *args, **kwargs)
-
- def dump_payload(self, obj):
- json = super(URLSafeSerializerMixin, self).dump_payload(obj)
- is_compressed = False
- compressed = zlib.compress(json)
- if len(compressed) < (len(json) - 1):
- json = compressed
- is_compressed = True
- base64d = base64_encode(json)
- if is_compressed:
- base64d = b"." + base64d
- return base64d
-
-
-class URLSafeSerializer(URLSafeSerializerMixin, Serializer):
- """Works like :class:`.Serializer` but dumps and loads into a URL
- safe string consisting of the upper and lowercase character of the
- alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
- """
-
-
-class URLSafeTimedSerializer(URLSafeSerializerMixin, TimedSerializer):
- """Works like :class:`.TimedSerializer` but dumps and loads into a
- URL safe string consisting of the upper and lowercase character of
- the alphabet as well as ``'_'``, ``'-'`` and ``'.'``.
- """