kes_tools
Python SDK for kes-tools: convert PDFs and Kurzweil 3000 .kes files into .kes files with OCR, layout and
reading order from Datalab, through the kes-tools website.
pip install kes-tools-sdk
from kes_tools import Client
with Client() as client:
for result in client.convert(["book.pdf", "chapter.kes"], output="converted"):
print(result.file, "->", result.output if result.ok else result.error)
Conversions run on the kes-tools website under your account and are billed to the Datalab account whose API key you
set up there. Client() uses the sign-in from kes-tools login (with pip install 'kes-tools-sdk[keyring]'), or
$KES_TOOLS_REFRESH_TOKEN; Client(refresh_token=...) uses the given one, and Client.login signs in through the
browser. All errors derive from KesToolsError.
The signed-in account. key_hint is the last four characters of the Datalab API key, if one is set up.
The kes-tools website answered a request with an error.
Not signed in, the sign-in expired or was revoked, or signing in failed.
A signed-in connection to the kes-tools website.
url defaults to $KES_TOOLS_URL or the public site. Without refresh_token, the sign-in comes from
$KES_TOOLS_REFRESH_TOKEN or the one kes-tools login (or Client.login) stored in the system keychain.
Use it as a context manager, or call close(), to release its connections.
Signs in through the browser, stores the sign-in in the keychain and returns the account's email.
Waits until the jobs are done or failed, or timeout seconds have passed; returns them in the same order,
with the status they had last.
Saves a done job's result in folder and returns its path. An existing file is kept and the new one gets
" (2)" etc. unless overwrite.
Converts .pdf and .kes files and saves the results in output, one result per file in the same order.
Raises MissingDatalabKey if the account has no Datalab API key. A file that fails to upload or convert gets a
result with error instead of raising. With wait=False the files are only uploaded and started; the
results then hold the jobs, for wait and download later. progress receives messages for people.
The outcome of converting one file with Client.convert: output is set when the converted file was saved,
error otherwise. job is None when the file could not be uploaded.
A conversion on the kes-tools website.
status is one of "awaiting_upload", "queued", "processing", "done" and "failed". cost_cents is what Datalab
billed, in US cents. download_url is set only on a done job fetched with Client.job and expires after a few
minutes; use Client.download instead of fetching it yourself.
Base class of the errors kes-tools raises.
The account has no Datalab API key; it can only be added in Settings on the website.