コード例 #1
0
ファイル: _fileio.py プロジェクト: laomobk/AIL
def _close(this):
    this = convert_to_pyobj(this)
    try:
        this.__this___buffer.close()
        this.__this_closed = True
    except Exception as e:
        return AILRuntimeError(str(e), 'PythonError')
コード例 #2
0
def print_all_error(exit=False, exit_code=1):
    es = MAIN_INTERPRETER_STATE.err_stack[::-1]

    for e in es:
        eo = convert_to_pyobj(e)
        print(unpack_ailobj(eo.__this_to_string)(e))

    if exit:
        sys.exit(exit_code)
コード例 #3
0
def _err_to_string(this):
    this = convert_to_pyobj(this)

    ofs = this.__this___offset
    msg = this.__this_err_msg
    type = this.__this_err_type
    where = this.__this_err_where

    return '%s%s : %s' % ('in \'%s\' + %s :\n\t' %
                          (where, ofs) if where else '', type, msg)
コード例 #4
0
ファイル: _fileio.py プロジェクト: laomobk/AIL
def _peek(this, size):
    this = convert_to_pyobj(this)
    size = unpack_ailobj(size)

    if type(size) != int:
        return AILRuntimeError('iobuffer.peek() needs an integer.')

    try:
        return this.__this___buffer.peek(size)
    except Exception as e:
        return AILRuntimeError(str(e), 'PythonError')
コード例 #5
0
ファイル: _fileio.py プロジェクト: laomobk/AIL
def _write(this, string):
    this = convert_to_pyobj(this)
    string = unpack_ailobj(string)
    buf = this.__this___buffer

    if type(string) != str:
        return AILRuntimeError('iobuffer.write() needs a string.')

    try:
        if not buf.writable():
            return AILRuntimeError('not writeable', 'OSError')

        return buf.write(string)
    except Exception as e:
        return AILRuntimeError(str(e), 'PythonError')
コード例 #6
0
ファイル: _fileio.py プロジェクト: laomobk/AIL
def _read(this, size):
    this = convert_to_pyobj(this)
    size = unpack_ailobj(size)
    buf = this.__this___buffer

    if type(size) != int:
        return AILRuntimeError('iobuffer.read() needs an integer.')

    try:
        if not buf.readable():
            return AILRuntimeError('not readable', 'OSError')

        return buf.read(size)
    except Exception as e:
        return AILRuntimeError(str(e), 'PythonError')
コード例 #7
0
 def _pop(this):
     this = convert_to_pyobj(this)
     if this.__this___stack:
         return this.__this___stack.pop()
     return null
コード例 #8
0
 def _empty(this):
     this = convert_to_pyobj(this)
     return len(this.__this___stack) == 0