forked from leancloud/python-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
34 lines (21 loc) · 626 Bytes
/
Copy pathutils.py
File metadata and controls
34 lines (21 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# coding: utf-8
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
import hashlib
import six
__author__ = "asaka <lan@leancloud.rocks>"
def sign_by_key(timestamp, key):
s = "{0}{1}".format(timestamp, key)
return hashlib.md5(s.encode("utf-8")).hexdigest()
if six.PY2:
def to_native(s):
if isinstance(s, unicode): # noqa: F821
return s.encode("utf-8")
return s
else:
def to_native(s):
if isinstance(s, bytes):
return s.decode("utf-8")
return s