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()
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
def __repr__(self): selstr = ffi.gc(lept.selPrintToString(self._cdata), lept.lept_free) return '<Sel \n' + ffi.string(selstr).decode('ascii') + '\n>'
def __getitem__(self, n): if 0 <= n < len(self): return ffi.string(self._cdata.array[n]) raise IndexError(n)