# Path: gymnast/pdf_constants.py
# WHITESPACE = frozenset((b' ', b'\t', b'\r', b'\n', b'\f', b'\x00'))


import io
import re
import struct
from functools import wraps
from .pdf_constants import WHITESPACE
    """Converts val to an unsinged int assuming a BE byte order"""
    try:
        return int.from_bytes(val, 'big')
    except AttributeError:
        # Older Python, so pad it and unpack
        return struct.unpack('>L', b'\x00'*(4-len(val))+val)[0]

def _is_buffered_bytesio(data):
    """Check if the argument is a buffered bytes io object"""
    if   not isinstance(data, io.BufferedIOBase):              return False
    elif not data.readable():                                  return False
    elif isinstance(data.raw, io.BytesIO):                     return True
    elif isinstance(data.raw, io.FileIO) and 'b' in data.mode: return True
    return False

def read_until(data, char_set):
    """Reads buffered io object until an element of char_set is encountered,
    returning the read data without the terminator."""
    result = io.BytesIO()
    char_set = set(char_set)
    c = data.read(1)
    while c and c not in char_set:
        result.write(c)
        c = data.read(1)
    return result.getvalue()

def is_digit(val):
    """Returns True if chr(val) is a digit 0-9"""
    return  48 <= val <= 57


# Path: gymnast/pdf_constants.py
# WHITESPACE = frozenset((b' ', b'\t', b'\r', b'\n', b'\f', b'\x00'))


# Path: gymnast/misc.py
import io
import re
import struct
from functools import wraps
from .pdf_constants import WHITESPACE

    """Converts val to an unsinged int assuming a BE byte order"""
    try:
        return int.from_bytes(val, 'big')
    except AttributeError:
        # Older Python, so pad it and unpack
        return struct.unpack('>L', b'\x00'*(4-len(val))+val)[0]

def _is_buffered_bytesio(data):
    """Check if the argument is a buffered bytes io object"""
    if   not isinstance(data, io.BufferedIOBase):              return False
    elif not data.readable():                                  return False
    elif isinstance(data.raw, io.BytesIO):                     return True
    elif isinstance(data.raw, io.FileIO) and 'b' in data.mode: return True
    return False

def read_until(data, char_set):
    """Reads buffered io object until an element of char_set is encountered,
    returning the read data without the terminator."""
    result = io.BytesIO()
    char_set = set(char_set)
    c = data.read(1)
    while c and c not in char_set:
        result.write(c)
        c = data.read(1)
    return result.getvalue()

def is_digit(val):
    """Returns True if chr(val) is a digit 0-9"""
    return  48 <= val <= 57


def consume_whitespace(data, whitespace=WHITESPACE):