# Path: qingcloud/misc/utils.py
# def get_utf8_value(value):
#     if sys.version < "3":
#         if isinstance(value, unicode):
#             return value.encode('utf-8')
#         if not isinstance(value, str):
#             value = str(value)
#         return value
#     else:
#         return str(value)
# 
# def get_ts(ts=None):
#     """ Get formatted time
#     """
#     if not ts:
#         ts = time.gmtime()
#     return time.strftime(ISO8601, ts)
# 
# def base64_url_decode(inp):
#     if sys.version > "3":
#         if isinstance(inp, bytes):
#             inp = inp.decode()
#         return base64.urlsafe_b64decode(inp + '=' * (4 - len(inp) % 4)).decode()
#     else:
#         return base64.urlsafe_b64decode(str(inp + '=' * (4 - len(inp) % 4)))
# 
# def base64_url_encode(inp):
#     if sys.version > "3":
#         if isinstance(inp, str):
#             inp = inp.encode()
#         return bytes.decode(base64.urlsafe_b64encode(inp).rstrip(b'='))
#     else:
#         return base64.urlsafe_b64encode(str(inp)).rstrip(b'=')


import sys
import hmac
import base64
import datetime
    import urllib.parse as urllib
    import urllib
from hashlib import sha1, sha256
from past.builtins import basestring
from qingcloud.misc.json_tool import json_dump, json_load
from qingcloud.misc.utils import get_utf8_value, get_ts, base64_url_decode,\
    base64_url_encode
# =========================================================================
# Copyright 2012-present Yunify, Inc.
# -------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================================================================


try:
    is_python3 = True
except:
    is_python3 = False



# List of query string arguments which should be signed
QSA_TO_SIGN = [
    "acl", "cors", "delete", "policy", "stats", "part_number", "uploads", "upload_id"

# Path: qingcloud/misc/utils.py
# def get_utf8_value(value):
#     if sys.version < "3":
#         if isinstance(value, unicode):
#             return value.encode('utf-8')
#         if not isinstance(value, str):
#             value = str(value)
#         return value
#     else:
#         return str(value)
# 
# def get_ts(ts=None):
#     """ Get formatted time
#     """
#     if not ts:
#         ts = time.gmtime()
#     return time.strftime(ISO8601, ts)
# 
# def base64_url_decode(inp):
#     if sys.version > "3":
#         if isinstance(inp, bytes):
#             inp = inp.decode()
#         return base64.urlsafe_b64decode(inp + '=' * (4 - len(inp) % 4)).decode()
#     else:
#         return base64.urlsafe_b64decode(str(inp + '=' * (4 - len(inp) % 4)))
# 
# def base64_url_encode(inp):
#     if sys.version > "3":
#         if isinstance(inp, str):
#             inp = inp.encode()
#         return bytes.decode(base64.urlsafe_b64encode(inp).rstrip(b'='))
#     else:
#         return base64.urlsafe_b64encode(str(inp)).rstrip(b'=')


# Path: qingcloud/conn/auth.py
import sys
import hmac
import base64
import datetime
    import urllib.parse as urllib
    import urllib
from hashlib import sha1, sha256
from past.builtins import basestring
from qingcloud.misc.json_tool import json_dump, json_load
from qingcloud.misc.utils import get_utf8_value, get_ts, base64_url_decode,\
    base64_url_encode

# =========================================================================
# Copyright 2012-present Yunify, Inc.
# -------------------------------------------------------------------------
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this work except in compliance with the License.
# You may obtain a copy of the License in the LICENSE file, or at:
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# =========================================================================


try:
    is_python3 = True
except:
    is_python3 = False



# List of query string arguments which should be signed
QSA_TO_SIGN = [
    "acl", "cors", "delete", "policy", "stats", "part_number", "uploads", "upload_id"

]