← Back to team overview

calibre-devs team mailing list archive

New resource and build API

 

Hi All,

Over the last week, I've implemented a new resource access and build API for
calibre. Previously, calibre used to store all it its resources like images and
fonts in a single py file from which they would be accessed. That has now
changed to storing the resources as individual files on the file system. This
was motivated by the growing number of needed resources, especially
translations.

calibre has a new builtin function named P that expands paths to resources.

So for example if you want the full platform dependent path to a file named

some_resource/some_file.xyz you would use

P('some_resource/some_file.xyz')

P will automatically interpret / as a path separator on windows as well and will
return the full path. For those interested, the definition of P is in
calibre.utils.resources

In addition there is an I function that is a shortcut for image access

P('images/logo.png) == I('logo.png')

Both, I and P accept an optional data keyword in which case they return the data
in the file instead of the path.

When compiling ui files, calibre automatically transates from the Qt resource
system to the calibre resource system.


Also, I completely rewrote the calibre build system, dropping the use of
setuptools/distutils.

python setup.py -h 

and the INSTALL file will give you details. Of particular interestmay be the
check command

python setup.py check

which uses pyflakes (you have to install that separately) to check all the
python files in the source tree for common errors.

Enjoy,

Kovid.
-- 
_____________________________________

Dr. Kovid Goyal 
http://www.kovidgoyal.net
http://calibre.kovidgoyal.net
_____________________________________

Attachment: pgpmFkDI9u7y9.pgp
Description: PGP signature