Mercurial > repos > guerler > hhblits
comparison lib/python3.8/site-packages/wheel/util.py @ 1:64071f2a4cf0 draft default tip
Deleted selected files
author | guerler |
---|---|
date | Mon, 27 Jul 2020 03:55:49 -0400 |
parents | 9e54283cc701 |
children |
comparison
equal
deleted
inserted
replaced
0:9e54283cc701 | 1:64071f2a4cf0 |
---|---|
1 import base64 | |
2 import io | |
3 import sys | |
4 | |
5 | |
6 if sys.version_info[0] < 3: | |
7 text_type = unicode # noqa: F821 | |
8 | |
9 StringIO = io.BytesIO | |
10 | |
11 def native(s, encoding='utf-8'): | |
12 if isinstance(s, unicode): # noqa: F821 | |
13 return s.encode(encoding) | |
14 return s | |
15 else: | |
16 text_type = str | |
17 | |
18 StringIO = io.StringIO | |
19 | |
20 def native(s, encoding='utf-8'): | |
21 if isinstance(s, bytes): | |
22 return s.decode(encoding) | |
23 return s | |
24 | |
25 | |
26 def urlsafe_b64encode(data): | |
27 """urlsafe_b64encode without padding""" | |
28 return base64.urlsafe_b64encode(data).rstrip(b'=') | |
29 | |
30 | |
31 def urlsafe_b64decode(data): | |
32 """urlsafe_b64decode without padding""" | |
33 pad = b'=' * (4 - (len(data) & 3)) | |
34 return base64.urlsafe_b64decode(data + pad) | |
35 | |
36 | |
37 def as_unicode(s): | |
38 if isinstance(s, bytes): | |
39 return s.decode('utf-8') | |
40 return s | |
41 | |
42 | |
43 def as_bytes(s): | |
44 if isinstance(s, text_type): | |
45 return s.encode('utf-8') | |
46 return s |