Manual de Calibre | Page 174

Manual de usuario de calibre, Publicación 2.73.0 swap_around_comma(val) class calibre.utils.formatter_functions.BuiltinSwapAroundComma swap_around_comma(val) – dado un valor de la forma «B, A», devuelve «A B». Esto es útil para convertir nombres en formato APELLIDO, NOMBRE a NOMBRE APELLIDO. Si no hay ninguna coma, la función devuelve «val» sin cambios. transliterate(a) class calibre.utils.formatter_functions.BuiltinTransliterate transliterate(a) – Devuelve un texto en el alfabeto latino formado por aproximación del sonido de las palabras en el texto origen. Por ejemplo, si el origen es «Фёдор Михaйлович Достоевский» la función devuelve «Fiodor Mikhailovich Dostoievskii». API of the Metadata objects The python implementation of the template functions is passed in a Metadata object. Knowing it’s API is useful if you want to define your own template functions. class calibre.ebooks.metadata.book.base.Metadata(title, authors=(u’Desconocido’, ), other=None, template_cache=None, formatter=None) A class representing all the metadata for a book. The various standard metadata fields are available as attributes of this object. You can also stick arbitrary attributes onto this object. Metadata from custom columns should be accessed via the get() method, passing in the lookup name for the column, for example: “#mytags”. Use the is_null() (página 170) method to test if a field is null. This object also has functions to format fields into strings. The list of standard metadata fields grows with time is in STANDARD_METADATA_FIELDS (página 171). Please keep the method based API of this class to a minimum. Every method becomes a reserved field name. is_null(field) Return True if the value of field is null in this object. ‘null’ means it is unknown or evaluates to False. So a title of _(‘Unknown’) is null or a language of ‘und’ is null. Be careful with numeric fields since this will return True for zero as well as None. Also returns True if the field does not exist. deepcopy(class_generator=>) Do not use this method unless you know what you are doing, if you want to create a simple clone of this object, use deepcopy_metadata() instead. Class_generator must be a function that returns an instance of Metadata or a subclass of it. get_identifiers() Return a copy of the identifiers dictionary. The dict is small, and the penalty for using a reference where a copy is needed is large. Also, we don’t want any manipulations of the returned dict to show up in the book. set_identifiers(identifiers) Set all identifiers. Note that if you previously set ISBN, calling this method will delete it. set_identifier(typ, val) If val is empty, deletes identifier of type typ 170 Capítulo 1. Secciones