ulif.openoffice.client – Python client for doc conversions

Client API to access all functionality via programmatic calls.

class ulif.openoffice.client.Client(cache_dir=None)

A client to trigger document conversions.

convert(src_doc_path, options={})

Convert src_doc_path according to options.

Calls convert_doc() internally and returns the result given by this function.

get_cached(cache_key)

Get the document from cache stored under cache_key.

Returns None if no such file can be found or no cache dir was set at all.

Warning

The returned path (if any) is part of cache! Do not remove or change the file. Copy it to another location instead.

New in version 1.1.

get_cached_by_source(src_doc_path, options={})

Get the document from cache by source doc and options.

Find a cached document, which was created from the given src_doc_path and options.

Returns the path to the document and a cache key you are encouraged to use for future access.

Please note that this method is much more expensive than get_cached(). Use it only if the cache_key returned upon registering a doc is absolutely not available any more.

Returns (None, None) if no such file can be found or no cache dir was set at all.

Warning

The returned path (if any) is part of cache! Do not remove or change the file. Copy it to another location instead.

New in version 1.1.

ulif.openoffice.client.convert_doc(src_doc, options, cache_dir)

Convert src_doc according to the other parameters.

src_doc is the path to the source document. options is a dict of options for processing, passed to the processors.

cache_dir may be None in which no caching is requested during processing.

Generates a converted representation of src_doc by calling ulif.openoffice.processor.MetaProcessor with options as parameters.

Afterwards the conversion result is stored in cache (if allowed/possible) for speedup of upcoming requests.

Returns a triple:

(<PATH>, <CACHE_KEY>, <METADATA>)

where <PATH> is the path to the resulting document, <CACHE_KEY> an identifier (string) to retrieve a generated doc from cache on future requests, and <METADATA> is a dict of values returned during request (and set by the document processors, notably setting the error keyword).

If errors happen or caching is disabled, <CACHE_KEY> is None.