Heray-Was-Here
Server : Apache
System : Linux vps37394.inmotionhosting.com 3.10.0-1160.119.1.vz7.224.4 #1 SMP Mon Sep 30 15:36:27 MSK 2024 x86_64
User : jasonp18 ( 1000)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /proc/3/root/proc/self/root/opt/imh-python/lib/python3.9/site-packages/construct/lib/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/3/root/proc/self/root/opt/imh-python/lib/python3.9/site-packages/construct/lib/py3compat.py
import sys, platform

PY = sys.version_info[:2]
PY2 = sys.version_info[0] == 2
PY3 = sys.version_info[0] == 3
PYPY = '__pypy__' in sys.builtin_module_names
ONWINDOWS = platform.system() == "Windows"

stringtypes = (bytes, str, )
integertypes = (int, )
unicodestringtype = str
bytestringtype = bytes

INT2BYTE_CACHE = {i:bytes([i]) for i in range(256)}
def int2byte(character):
    """Converts (0 through 255) integer into b'...' character."""
    return INT2BYTE_CACHE[character]

def byte2int(character):
    """Converts b'...' character into (0 through 255) integer."""
    return character[0]

def str2bytes(string):
    """Converts '...' string into b'...' string. On PY2 they are equivalent. On PY3 its utf8 encoded."""
    return string.encode("utf8")

def bytes2str(string):
    """Converts b'...' string into '...' string. On PY2 they are equivalent. On PY3 its utf8 decoded."""
    return string.decode("utf8")

def reprstring(data):
    """Ensures there is b- u- prefix before the string."""
    if isinstance(data, bytes):
        return repr(data)
    if isinstance(data, str):
        return 'u' + repr(data)

def trimstring(data):
    """Trims b- u- prefix"""
    if isinstance(data, bytes):
        return repr(data)[1:]
    if isinstance(data, str):
        return repr(data)

def integers2bytes(ints):
    """Converts integer generator into bytes."""
    return bytes(ints)

def bytes2integers(data):
    """Converts bytes into integer list, so indexing/iterating yields integers."""
    return list(data)

Hry