Exemplo n.º 1
0
def get_leptonica_version():
    """Get Leptonica version string.

    Caveat: Leptonica expects the caller to free this memory.  We don't,
    since that would involve binding to libc to access libc.free(),
    a pointless effort to reclaim 100 bytes of memory.
    """
    return ffi.string(lept.getLeptonicaVersion()).decode()
Exemplo n.º 2
0
def _stderr_handler(cstr):
    msg = ffi.string(cstr).decode(errors='replace')
    if msg.startswith("Error"):
        logger.error(msg)
    elif msg.startswith("Warning"):
        logger.warning(msg)
    else:
        logger.debug(msg)
    if tls.trap is not None:
        tls.trap.append(msg)
    return
Exemplo n.º 3
0
 def __repr__(self):
     selstr = ffi.gc(lept.selPrintToString(self._cdata), lept.lept_free)
     return '<Sel \n' + ffi.string(selstr).decode('ascii') + '\n>'
Exemplo n.º 4
0
 def __getitem__(self, n):
     if 0 <= n < len(self):
         return ffi.string(self._cdata.array[n])
     raise IndexError(n)