GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

_libmuprivpython2.py 579 Bytes
Newer Older
Kunshan Wang's avatar
Kunshan Wang committed
1 2 3 4 5 6 7
from __future__ import division, absolute_import, print_function, unicode_literals

from _libmuprivcommon import _assert_instance

def _is_str_like(v):
    return isinstance(v, str) or isinstance(v, unicode)

8
def _encode(v, encoding):
Kunshan Wang's avatar
Kunshan Wang committed
9 10
    _assert_instance(v, str, unicode)
    if isinstance(v, unicode):
11
        return v.encode(encoding)
Kunshan Wang's avatar
Kunshan Wang committed
12 13 14
    else:
        return v

15
def _decode(v, encoding):
Kunshan Wang's avatar
Kunshan Wang committed
16 17
    _assert_instance(v, str, unicode)
    if isinstance(v, str):
18
        return v.decode(encoding)
Kunshan Wang's avatar
Kunshan Wang committed
19 20 21 22 23
    else:
        return v

def _assert_int_like(v):
    _assert_instance(v, int, long)