calibreUserManual,Release2.55.0
Catalogplugins
classcalibre.customize.CatalogPlugin(plugin_path)
Bases:calibre.customize.Plugin(page193)
Apluginthatimplementsacataloggenerator.
file_types=set([])
OutputfiletypeforwhichthispluginshouldberunForexample:‘epub’or‘xml’
cli_options=[]
CLIparseroptionsspecifictothisplugin,declaredasnamedtupleOption:
from collections import namedtuple
Option namedtuple('Option''option, default, , dest, help')
cli_options [Option('--catalog-title',
default 'My Catalog',
dest 'catalog_title',
help (_('Title of f generated d catalog. \nDefault:'" '" +
'%default' "'"))]
cli_options parsed in library.cli:catalog_option_parser()
initialize()
Ifpluginisnotabuilt-in,copytheplugin’s.uiand.pyfilesfromthezipfileto$TMPDIR.Tabwillbe
dynamicallygeneratedandaddedtotheCatalogOptionsdialogincalibre.gui2.dialogs.catalog.py:Catalog
run(path_to_output,opts,db,ids,notification=None)
Runtheplugin.Mustbeimplementedinsubclasses.Itshouldgeneratethecatalogintheformatspecified
infile_types,returningtheabsolutepathtothegeneratedcatalogfile.Ifanerrorisencountereditshould
raiseanException.
Thegeneratedcatalogfileshouldbecreatedwiththetemporary_file()method.
Parameters
• path_to_output–Absolutepathtothegeneratedcatalogfile.
• opts–Adictionaryofkeywordarguments
• db–ALibraryDatabase2object
Metadatadownloadplugins
classcalibre.ebooks.metadata.sources.base.Source(*args,**kwargs)
Bases:calibre.customize.Plugin(page193)
capabilities=frozenset([])
Setofcapabilitiessupportedbythisplugin.Usefulcapabilitiesare:‘identify’,‘cover’
touched_fields=frozenset([])
Listofmetadatafieldsthatcanpotentiallybedownloadbythispluginduringtheidentifyphase
has_html_comments=False
SetthistoTrueifyourpluginreturnsHTMLformattedcomments
supports_gzip_transfer_encoding=False
SettingthistoTruemeansthatthebrowserobjectwilladdAccept-Encoding:gziptoallrequests.Thiscan
speedupdownloadsbutmakesurethatthesourceactuallysupportsgziptransferencodingcorrectlyfirst
1.10. Customizingcalibre
197
Convert pdf to powerpoint slides - C# Create PDF from PowerPoint Library to convert pptx, ppt to PDF in C#.net, ASP.NET MVC, WinForms, WPF
Online C# Tutorial for Creating PDF from Microsoft PowerPoint Presentation
how to convert pdf slides to powerpoint; embed pdf into powerpoint
Convert pdf to powerpoint slides - VB.NET Create PDF from PowerPoint Library to convert pptx, ppt to PDF in vb.net, ASP.NET MVC, WinForms, WPF
VB.NET Tutorial for Export PDF file from Microsoft Office PowerPoint
how to convert pdf slides to powerpoint presentation; how to change pdf to powerpoint format
calibreUserManual,Release2.55.0
cached_cover_url_is_reliable=True
CachedcoverURLscansometimesbeunreliable(i.e.thedownloadcouldfailorthereturnedimagecould
bebogus.IfthatisoftenthecasewiththissourcesettoFalse
options=()
AlistofOptionobjects. Theywillbeusedtoautomaticallyconstructtheconfigurationwidgetforthis
plugin
config_help_message=None
Astringthatisdisplayedatthetopoftheconfigwidgetforthisplugin
can_get_multiple_covers=False
IfTruethissourcecanreturnmultiplecoversforagivenquery
auto_trim_covers=False
IfsettoTruecoversdownloadedbythispluginareautomaticallytrimmed.
prefer_results_with_isbn=True
IfsettoTrue,andthissourcereturnsmultipleresultsforaquery,someofwhichhaveISBNsandsomeof
whichdonot,theresultswithoutISBNswillbeignored
is_configured()
ReturnFalseifyourpluginneedstobeconfiguredbeforeitcanbeused. Forexample,itmightneeda
username/password/APIkey.
get_author_tokens(authors,only_first_author=True)
TakealistofauthorsandreturnalistoftokensusefulforanANDsearchquery. Thisfunctiontriesto
returntokensinfirstnamemiddlenameslastnameorder,byassumingthatifacommaisintheauthor
name,thenameisinlastname,othernamesform.
get_title_tokens(title,strip_joiners=True,strip_subtitle=False)
TakeatitleandreturnalistoftokensusefulforanANDsearchquery. Excludesconnectives(optionally)
andpunctuation.
split_jobs(jobs,num)
Splitalistofjobsintoatmostnumgroups,asevenlyaspossible
test_fields(mi)
Returnthefirstfieldfromself.touched_fieldsthatisnullonthemiobject
clean_downloaded_metadata(mi)
Callthismethodinyourplugin’sidentifymethodtonormalizemetadatabeforeputtingtheMetadataobject
intoresult_queue.Youcanofcourse,useacustomalgorithmsuitedtoyourmetadatasource.
get_book_url(identifiers)
Returna3-tupleorNone. The3-tupleisoftheform:(identifier_type,identifier_value,URL).TheURL
istheURLforthebookidentifiedbyidentifiersatthissource.identifier_type,identifier_valuespecifythe
identifiercorrespondingtotheURL.ThisURLmustbebrowseabletobyahumanusingabrowser. Itis
meanttoprovideaclickablelinkfortheusertoeasilyvisitthebookspageatthissource. IfnoURLis
found,returnNone. Thismethodmustbequick,andconsistent,soonlyimplementitifitispossibleto
constructtheURLfromaknownschemegivenidentifiers.
get_book_url_name(idtype,idval,url)
Returnahumanreadablenamefromthereturnvalueofget_book_url().
get_book_urls(identifiers)
Overridethismethodifyouwouldliketoreturnmultipleurlsforthisbook.Returnalistof3-tuples. By
defaultthismethodsimplycallsget_book_url()(page198).
get_cached_cover_url(identifiers)
ReturncachedcoverURLforthebookidentifiedbytheidentifiersdictorNoneifnosuchURLexists.
198
Chapter1. Sections
C# PowerPoint - How to Process PowerPoint
Microsoft PowerPoint Document Processing Control in Visual C#.NET of RasterEdge .NET Imaging SDK is a reliable and professional PowerPoint slides/pages editing
how to convert pdf to powerpoint on; pdf to ppt converter
VB.NET PowerPoint: Process & Manipulate PPT (.pptx) Slide(s)
add image to slide, extract slides and merge library SDK, this VB.NET PowerPoint processing control powerful & profession imaging controls, PDF document, image
add pdf to powerpoint presentation; convert pdf file into ppt
calibreUserManual,Release2.55.0
NotethatthismethodmustonlyreturnvalidatedURLs,i.e.notURLSthatcouldresultinagenericcover
imageoranotfounderror.
identify_results_keygen(title=None,authors=None,identifiers={})
ReturnafunctionthatisusedtogenerateakeythatcansortMetadataobjectsbytheirrelevancegivena
searchquery(title,authors,identifiers).
Thesekeysareusedtosorttheresultsofacalltoidentify()(page199).
For details s on n the default algorithm m see InternalMetadataCompareKeyGen (page 199). . Re-
implementthisfunctioninyourpluginifthedefaultalgorithmisnotsuitable.
identify(log,result_queue,abort,title=None,authors=None,identifiers={},timeout=30)
Identifyabookbyitstitle/author/isbn/etc.
Ifidentifiers(s)arespecifiedandnomatchisfoundandthismetadatasourcedoesnotstoreallrelated
identifiers (forexample,allISBNsofabook),thismethodshouldretrywithjustthetitleandauthor
(assumingtheywerespecified).
Ifthismetadatasourcealsoprovidescovers,theURLtothecovershouldbecachedsothatasubsequent
calltothegetcoversAPIwiththesameISBN/specialidentifierdoesnotneedtogetthecoverURLagain.
UsethecachingAPIforthis.
EveryMetadataobjectputintoresult_queuebythismethodmusthaveasource_relevanceattributethat
isanintegerindicatingtheorderinwhichtheresultswerereturnedbythemetadatasourceforthisquery.
Thisintegerwillbeusedbycompare_identify_results(). Iftheorderisunimportant,setitto
zeroforeveryresult.
Makesurethatanycover/isbnmappinginformationiscachedbeforetheMetadataobjectisputintore-
sult_queue.
Parameters
• log–Alogobject,useittooutputdebugginginformation/errors
• result_queue–AresultQueue,resultsshouldbeputintoit.EachresultisaMetadata
object
• abort–Ifabort.is_set()returnsTrue, , abortfurtherprocessingandreturnas soonas
possible
• title–Thetitleofthebook,canbeNone
• authors–Alistofauthorsofthebook,canbeNone
• identifiers–Adictionaryofotheridentifiers,mostcommonly{‘isbn’:‘1234...’}
• timeout–Timeoutinseconds,nonetworkrequestshouldhangforlongerthantimeout.
Returns Noneifnoerrorsoccurred,otherwiseaunicoderepresentationoftheerrorsuitablefor
showingtotheuser
download_cover(logresult_queueaborttitle=Noneauthors=Noneidentifiers={}timeout=30,
get_best_cover=False)
Download acover and put itinto result_queue. . Theparameters s all have the same meaningas s for
identify()(page199).Put(self,cover_data)intoresult_queue.
ThismethodshouldusecachedcoverURLsforefficiencywheneverpossible. Whencacheddataisnot
present,mostpluginssimplycallidentifyanduseitsresults.
Iftheparameterget_best_coverisTrueandthisplugincangetmultiplecovers, itshouldonlygetthe
“best”one.
1.10. Customizingcalibre
199
VB.NET PowerPoint: Sort and Reorder PowerPoint Slides by Using VB.
clip art or screenshot to PowerPoint document slide large amount of robust PPT slides/pages editing powerful & profession imaging controls, PDF document, image
how to convert pdf into powerpoint on; pdf into powerpoint
VB.NET PowerPoint: Use PowerPoint SDK to Create, Load and Save PPT
Besides, users also can get the precise PowerPoint slides count as soon as the PowerPoint document has been loaded by using the page number getting method.
image from pdf to ppt; change pdf to powerpoint online
calibreUserManual,Release2.55.0
classcalibre.ebooks.metadata.sources.base.InternalMetadataCompareKeyGen(mi,
source_plugin,
title,
au-
thors,
iden-
ti-
fiers)
GenerateasortkeyforcomparisonoftherelevanceofMetadataobjects,givenasearchquery.Thisisusedonly
tocompareresultsfromthesamemetadatasource,notacrossdifferentsources.
Thesortkeyensuresthatanascendingordersortisasortbyorderofdecreasingrelevance.
Thealgorithmis:
•Preferresultsthathaveatleastoneidentifierthesameasforthequery
•PreferresultswithacachedcoverURL
•Preferresultswithallavailablefieldsfilledin
•Preferresultswiththesamelanguageasthecurrentuserinterfacelanguage
•Preferresultsthatareanexacttitlematchtothequery
•Preferresultswithlongercomments(greaterthan10%longer)
•Usetherelevanceoftheresultasreportedbythemetadatasource’ssearch engine
Conversionplugins
classcalibre.customize.conversion.InputFormatPlugin(*args)
Bases:calibre.customize.Plugin(page193)
InputFormatPluginsareresponsibleforconvertingadocumentintoHTML+OPF+CSS+etc. Theresultsofthe
conversionmustbeencodedinUTF-8.Themainactionhappensinconvert()(page201).
file_types=set([])
SetoffiletypesforwhichthispluginshouldberunForexample:set([’azw’, ’mobi’, , ’prc’])
is_image_collection=False
IfTrue,thisinputplugingeneratesacollectionofimages,oneperHTMLfile.Thiscanbesetdynamically,
intheconvertmethodiftheinputfilescanbebothimagecollectionsandnon-imagecollections.Ifyouset
thistoTrue,youmustimplementtheget_images()methodthatreturnsalistofimages.
core_usage=1
NumberofCPUcoresusedbythispluginAvalueof-1meansthatitusesallavailablecores
for_viewer=False
IfsettoTrue,theinputpluginwillperformspecialprocessingtomakeitsoutputsuitableforviewing
output_encoding=‘utf-8’
Theencodingthatthisinputplugincreatesfilesin.AvalueofNonemeansthattheencodingisundefined
andmustbedetectedindividually
common_options=set([<calibre.customize.conversion.OptionRecommendationobjectat0x7fad3b5ed3d0>])
OptionssharedbyallInputformatplugins. Donotoverrideinsub-classes. . Useoptions(page200)
instead.EveryoptionmustbeaninstanceofOptionRecommendation.
options=set([])
Options to customize e the behavior r of this plugin.
Every option must be e an n instance e of
OptionRecommendation.
200
Chapter1. Sections
VB.NET PowerPoint: Extract & Collect PPT Slide(s) Using VB Sample
want to combine these extracted slides into a please read this VB.NET PowerPoint slide processing powerful & profession imaging controls, PDF document, image
create powerpoint from pdf; add pdf to powerpoint slide
VB.NET PowerPoint: Merge and Split PowerPoint Document(s) with PPT
of the split PPT document will contain slides/pages 1-4 code in VB.NET to finish PowerPoint document splitting If you want to see more PDF processing functions
convert pdf to editable ppt; images from pdf to powerpoint
calibreUserManual,Release2.55.0
recommendations=set([])
Asetof3-tuplesoftheform(option_name,recommended_value,recommendation_level)
get_images()
Returnalistofabsolutepathstotheimages,ifthisinputpluginrepresentsanimagecollection.Thelistof
imagesisinthesameorderasthespineandtheTOC.
convert(stream,options,file_ext,log,accelerators)
Thismethodmustbeimplementedinsub-classes. ItmustreturnthepathtothecreatedOPFfileoran
OEBBookinstance. Alloutputshouldbecontainedinthecurrentdirectory. Ifthisplugincreatesfiles
outsidethecurrentdirectorytheymustbedeleted/markedfordeletionbeforethismethodreturns.
Parameters
• stream–Afilelikeobjectthatcontainstheinputfile.
• options–Optionstocustomizetheconversionprocess. . Guaranteedtohaveattributes
corresponding toall the options s declared d by this s plugin. . Inaddition, , it will have e a
verboseattributethattakesintegralvaluesfromzeroupwards. Highernumbersmean
bemoreverbose. Anotherusefulattributeisinput_profilethatisaninstanceof
calibre.customize.profiles.InputProfile.
• file_ext–Theextension(withoutthe.)oftheinputfile.Itisguaranteedtobeoneof
thefile_typessupportedbythisplugin.
• log–Acalibre.utils.logging.Logobject.Alloutputshouldusethisobject.
• accelarators–Adictionaryofvariousinformationthattheinputplugincangeteasily
thatwouldspeedupthesubsequentstagesoftheconversion.
postprocess_book(oeb,opts,log)
Calledtoallowtheinputplugintoperformpostprocessingafterthebookhasbeenparsed.
specialize(oeb,opts,log,output_fmt)
Calledtoallowtheinputplugintospecializetheparsedbookforaparticularoutputformat. Calledafter
postprocess_bookandbeforeanytransformsareperformedontheparsedbook.
gui_configuration_widget(parent,get_option_by_name,get_option_help,db,book_id=None)
CalledtocreatethewidgetusedforconfiguringthisplugininthecalibreGUI.Thewidgetmustbean
instanceofthePluginWidgetclass.Seethebuiltininputpluginsforexamples.
classcalibre.customize.conversion.OutputFormatPlugin(*args)
Bases:calibre.customize.Plugin(page193)
OutputFormatPluginsareresponsibleforconvertinganOEBdocument(OPF+HTML)intoanoutputebook.
TheOEBdocumentcanbeassumedtobeencodedinUTF-8. The e mainaction happensinconvert()
(page201).
file_type=None
Thefiletype(extensionwithoutleadingperiod)thatthispluginoutputs
common_options=set([<calibre.customize.conversion.OptionRecommendationobjectat0x7fad3b5ed550>])
OptionssharedbyallInputformatplugins. Donotoverrideinsub-classes. . Useoptions(page201)
instead.EveryoptionmustbeaninstanceofOptionRecommendation.
options=set([])
Options to customize e the behavior r of this plugin.
Every option must be e an n instance e of
OptionRecommendation.
recommendations=set([])
Asetof3-tuplesoftheform(option_name,recommended_value,recommendation_level)
1.10. Customizingcalibre
201
VB.NET PowerPoint: Complete PowerPoint Document Conversion in VB.
VB.NET PowerPoint Conversion Control to render and convert target PowerPoint document to various image or document formats, such as PDF, BMP, TIFF
image from pdf to powerpoint; converting pdf to ppt
VB.NET PowerPoint: Convert & Render PPT into PDF Document
Using this VB.NET PowerPoint to PDF converting demo code below, you can easily convert all slides of source PowerPoint document into a multi-page PDF file.
convert pdf into powerpoint online; pdf to powerpoint slide
calibreUserManual,Release2.55.0
convert(oeb_book,output,input_plugin,opts,log)
Renderthecontentsofoeb_book(whichisaninstanceofcalibre.ebooks.oeb.OEBBooktothe
filespecifiedbyoutput.
Parameters
• output–Eitherafilelikeobjectorastring. . Ifitisastringitisthepathtoadirectory
thatmayormaynotexist.Theoutputpluginshouldwriteitsoutputintothatdirectory.If
itisafilelikeobject,theoutputpluginshouldwriteitsoutputintothefile.
• input_plugin–Theinputpluginthatwasusedatthebeginningoftheconversion
pipeline.
• opts–Conversionoptions. . GuaranteedtohaveattributescorrespondingtotheOption-
Recommendationsofthisplugin.
• log–Thelogger.Printdebug/infomessagesetc.usingthis.
specialize_css_for_output(log,opts,item,stylizer)
CanbeusedtomakechangestothecssduringtheCSSflatteningprocess.
Parameters
• item–Theitem(HTMLfile)beingprocessed
• stylizer–AStylizerobjectcontainingtheflattenedstylesforitem. Youcangetthe
styleforanyelementbystylizer.style(element).
gui_configuration_widget(parent,get_option_by_name,get_option_help,db,book_id=None)
CalledtocreatethewidgetusedforconfiguringthisplugininthecalibreGUI.Thewidgetmustbean
instanceofthePluginWidgetclass.Seethebuiltinoutputpluginsforexamples.
DeviceDrivers
ThebaseclassforalldevicedriversisDevicePlugin(page202). However,ifyourdeviceexposesitselfasa
USBMSdrivetotheoperatingsystem,youshouldusetheUSBMSclassinsteadasitimplementsallthelogicneeded
tosupportthesekindsofdevices.
classcalibre.devices.interface.DevicePlugin(plugin_path)
Bases:calibre.customize.Plugin(page193)
Definestheinterfacethatshouldbeimplementedbybackendsthatcommunicatewithanebookreader.
FORMATS=[’lrf’,‘rtf’,‘pdf’,‘txt’]
Orderedlistofsupportedformats
VENDOR_ID=0
VENDOR_IDcanbeeitheraninteger,alistofintegersoradictionaryIfitisadictionary,itmustbea
dictionaryofdictionaries,oftheform:
{
integer_vendor_id : : { product_id : : [list of f BCDs], ... },
...
}
PRODUCT_ID=0
Anintegeroralistofintegers
BCD=None
BCDcanbeeitherNonetonotdistinguishbetweendevicesbasedonBCD,oritcanbealistoftheBCD
numbersofalldevicessupportedbythisdriver.
202
Chapter1. Sections
VB.NET PowerPoint: Add Image to PowerPoint Document Slide/Page
insert or delete any certain PowerPoint slide without methods to reorder current PPT slides in both powerful & profession imaging controls, PDF document, tiff
change pdf to powerpoint; convert pdf to powerpoint slides
C# PowerPoint: C# Guide to Add, Insert and Delete PPT Slide(s)
file and it includes all slides and properties to view detailed guide for each PowerPoint slide processing & profession imaging controls, PDF document, tiff
add pdf to powerpoint; how to change pdf file to powerpoint
calibreUserManual,Release2.55.0
THUMBNAIL_HEIGHT=68
Heightforthumbnailsonthedevice
THUMBNAIL_COMPRESSION_QUALITY=75
Widthforthumbnailsonthedevice. Settingthiswillforcethumbnailstothissize,notpreservingaspect
ratio. Ifitisnotset,thentheaspectratiowillbepreservedandthethumbnailwillbenohigherthan
THUMBNAIL_HEIGHTCompressionqualityforthumbnails.Setthiscloserto100tohavebetterquality
thumbnailswithfewercompressionartifacts.Ofcourse,thethumbnailsgetlargeraswell.
WANTS_UPDATED_THUMBNAILS=False
SetthistoTrueifthedevicesupportsupdatingcoverthumbnailsduringsync_booklists.Settingittotrue
willaskdevice.pytorefreshthecoverthumbnailsduringbookmatching
CAN_SET_METADATA=[’title’,‘authors’,‘collections’]
WhetherthemetadataonbookscanbesetviatheGUI.
CAN_DO_DEVICE_DB_PLUGBOARD=False
Whetherthedevicecanhandledevice_dbmetadataplugboards
path_sep=‘/’
Pathseparatorforpathstobooksondevice
icon=‘/home/kovid/work/calibre/resources/images/reader.png’
Iconforthisdevice
UserAnnotation
aliasofAnnotation
OPEN_FEEDBACK_MESSAGE=None
GUIdisplaysthisasamessageifnotNone.Usefulifopeningcantakealongtime
VIRTUAL_BOOK_EXTENSIONS=frozenset([])
Setofextensionsthatare“virtualbooks”onthedeviceandthereforecannotbeviewed/saved/addedto
library.Forexample:frozenset([’kobo’])
VIRTUAL_BOOK_EXTENSION_MESSAGE=None
Messagetodisplaytouserforvirtualbookextensions.
NUKE_COMMENTS=None
Whethertonukecommentsinthecopyofthebooksenttothedevice. IfnotNonethisshouldbeshort
stringthatthecommentswillbereplacedby.
MANAGES_DEVICE_PRESENCE=False
IfTrueindicatesthatthisdrivercompletelymanagesdevicedetection,ejectingandsoforth.Ifyousetthis
toTrue,youmustimplementthedetect_managed_devicesanddebug_managed_device_detectionmeth-
ods.Adriverwiththissettotrueisresponsiblefordetectionofdevices,managingablacklistofdevices,
alistofejecteddevicesandsoforth. calibrewillperiodicallycallthedetect_managed_devices()method
andifitreturnsadetecteddevice,calibrewillcallopen(). open()willbecalledeverytimeadeviceis
returnedevenispreviouscallstoopen()failed, thereforethedrivermustmaintainitsownblacklistof
faileddevices. Similarly,whenejecting,calibrewillcalleject()andthenassumingthenextcalltode-
tect_managed_devices()returnsNone,itwillcallpost_yank_cleanup().
SLOW_DRIVEINFO=False
IfsettheTrue,calibrewillcalltheget_driveinfo()(page205)methodafterthebookslistshave
beenloadedtogetthedriveinfo.
ASK_TO_ALLOW_CONNECT=False
If set to True, , calibre e will l ask the user if they want to manage the device with calibre, the first
time itis detected. . Ifyouset t this to True you mustimplementget_device_uid()(page 208)
and ignore_connected_device() (page 208) and get_user_blacklisted_devices()
(page208)andset_user_blacklisted_devices()(page208)
1.10. Customizingcalibre
203
calibreUserManual,Release2.55.0
user_feedback_after_callback=None
Setthistoadictionaryoftheform{‘title’:title,‘msg’:msg,‘det_msg’:detailed_msg}tohavecalibrepopup
amessagetotheuseraftersomecallbacksarerun(currentlyonlyupload_books).Becarefultonotspam
theuserwithtoomanymessages. Thisvariableischeckedaftereverycallback,soonlysetitwhenyou
reallyneedto.
is_usb_connected(devices_on_system,debug=False,only_presence=False)
ReturnTrue,device_infoifadevicehandledbythispluginiscurrentlyconnected.
Parameters devices_on_system–Listofdevicescurrentlyconnected
detect_managed_devices(devices_on_system,force_refresh=False)
CalledonlyifMANAGES_DEVICE_PRESENCEisTrue.
Scanfordevicesthatthisdrivercanhandle.Shouldreturnadeviceobjectifadeviceisfound.Thisobject
willbepassedtotheopen()methodastheconnected_device. Ifnodeviceisfound, , returnNone. . The
returnedobjectcanbeanything,calibredoesnotuseit,itisonlypassedtoopen().
ThismethodiscalledperiodicallybytheGUI,somakesureitisnottooresourceintensive. Useacache
toavoidrepeatedlyscanningthesystem.
Parameters
• devices_on_system–SetofUSBdevicesfoundonthesystem.
• force_refresh–IfTrueandthedriverusesacachetopreventrepeatedscanning,the
cachemustbeflushed.
debug_managed_device_detection(devices_on_system,output)
CalledonlyifMANAGES_DEVICE_PRESENCEisTrue.
Shouldwriteinformationaboutthedevicesdetectedonthesystemtooutput,whichisafilelikeobject.
ShouldreturnTrueifadevicewasdetectedandsuccessfullyopened,otherwiseFalse.
reset(key=’-1’,log_packets=False,report_progress=None,detected_device=None)
Parameters
• key–Thekeytounlockthedevice
• log_packets–Iftruethepacketstreamto/fromthedeviceislogged
• report_progress–Functionthatiscalledwitha%progress(numberbetween0and
100)forvarioustasksIfitiscalledwith-1thatmeansthatthetaskdoesnothaveany
progressinformation
• detected_device–Deviceinformationfromthedevicescanner
can_handle_windows(usbdevice,debug=False)
Optionalmethodtoperformfurtherchecksonadevicetoseeifthisdriveriscapableofhandlingit. If
itisnotitshouldreturnFalse. Thismethodisonlycalledafterthevendor,productidsandthebcdhave
matched,soitcandosomerelativelytimeintensivechecks.ThedefaultimplementationreturnsTrue.This
methodiscalledonlyonwindows.Seealsocan_handle()(page204).
NotethatfordevicesbasedonUSBMSthismethodbydefaultdelegatestocan_handle()(page204).
Soyouonlyneedtooverridecan_handle()(page204)inyoursubclassofUSBMS.
Parameters usbdevice
A
usbdevice
as
returned
by
calibre.devices.winusb.scan_usb_devices()
can_handle(device_info,debug=False)
Unixversionofcan_handle_windows()(page204).
Parameters device_info–Isatupleof(vid,pid,bcd,manufacturer,product,serialnumber)
204
Chapter1. Sections
calibreUserManual,Release2.55.0
open(connected_device,library_uuid)
Perform any y device e specific initialization. . Called d after the e device e is s detected but before e any
other functions s that communicate with h the device. . For r example: : For r devices s that present them-
selves as USB Mass storage devices, , this s method d would be responsible for r mounting g the device
or if the e device e has s been automounted, for finding out t where it has s been mounted. . The e method
calibre.devices.usbms.device.Device.open()hasanimplementationofthisfunctionthat
shouldserveasagoodexampleforUSBMassstoragedevices.
ThismethodcanraiseanOpenFeedbackexceptiontodisplayamessagetotheuser.
Parameters
• connected_device–Thedevicethatwearetryingtoopen. . Itisatupleof(vendor
id,productid,bcd,manufacturername,productname,deviceserialnumber). However,
somedeviceshavenoserialnumberandonwindowsonlythefirstthreefieldsarepresent,
therestareNone.
• library_uuid–TheUUIDofthecurrentcalibrelibrary. . CanbeNoneifthereisno
library(forexamplewhenusedfromthecommandline).
eject()
Un-mount/ejectthedevicefromtheOS.ThisdoesnotcheckiftherearependingGUIjobsthatneedto
communicatewiththedevice.
NOTE:Thatthismethodmaynotbecalledonthesamethreadastherestofthedevicemethods.
post_yank_cleanup()
Callediftheuseryanksthedevicewithoutejectingitfirst.
set_progress_reporter(report_progress)
Setafunctiontoreportprogressinformation.
Parameters report_progress–Functionthatiscalledwitha%progress(numberbetween
0and100)forvarioustasksIfitiscalledwith-1thatmeansthatthetaskdoesnothaveany
progressinformation
get_device_information(end_session=True)
Askdevicefordeviceinformation.SeeL{DeviceInfoQuery}.
Returns (devicename,deviceversion,softwareversionondevice,mimetype)Thetuplecan
optionallyhaveafifthelement,whichisadriveinformationdictionary.Seeusbms.driverfor
anexample.
get_driveinfo()
Returnthedriveinfodictionary.Usuallycalledfromget_device_information(),butifloadingthedriveinfo
isslowforthisdriver,thenitshouldsetSLOW_DRIVEINFO.Inthiscase,thismethodwillbecalledby
calibreafterthebooklistshavebeenloaded. Notethatitisnotcalledonthedevicethread,sothedriver
shouldcachethedriveinfointhebooks()methodandthisfunctionshouldreturnthecacheddata.
card_prefix(end_session=True)
Returna2elementlistoftheprefixtopathsonthecards. IfnocardispresentNoneissetforthecard’s
prefix.E.G.(‘/place’,‘/place2’)(None,‘place2’)(‘place’,None)(None,None)
total_space(end_session=True)
Gettotalspaceavailableonthemountpoints:
1. Mainmemory
2. MemoryCardA
3. MemoryCardB
1.10. Customizingcalibre
205
calibreUserManual,Release2.55.0
Returns A3elementlistwithtotalspaceinbytesof(1,2,3).Ifaparticulardevicedoesn’thave
anyoftheselocationsitshouldreturn0.
free_space(end_session=True)
Getfreespaceavailableonthemountpoints:
1. Mainmemory
2. CardA
3. CardB
Returns A3elementlistwithfreespaceinbytesof(1,2,3).Ifaparticulardevicedoesn’thave
anyoftheselocationsitshouldreturn-1.
books(oncard=None,end_session=True)
Returnalistofebooksonthedevice.
Parameters oncard–If‘carda’or‘cardb’returnalistofebooksonthespecificstoragecard,
otherwisereturnlistofebooksinmainmemoryofdevice.Ifacardisspecifiedandnobooks
areonthecardreturnemptylist.
Returns ABookList.
upload_books(files,names,on_card=None,end_session=True,metadata=None)
Uploadalistofbookstothedevice. Ifafilealreadyexistsonthedevice,itshouldbereplaced. This
methodshouldraiseaFreeSpaceErrorifthereisnotenoughfreespaceonthedevice.Thetextofthe
FreeSpaceErrormustcontaintheword“card”ifon_cardisnotNoneotherwiseitmustcontaintheword
“memory”.
Parameters
• files–Alistofpaths
• names–Alistoffilenamesthatthebooksshouldhaveonceuploadedtothedevice.
len(names)==len(files)
• metadata–IfnotNone,itisalistofMetadataobjects.Theideaistousethemetadata
todeterminewhereonthedevicetoputthebook.len(metadata)==len(files).Apartfrom
theregularcover(pathtocover),theremayalsobeathumbnailattribute,whichshouldbe
usedinpreference. Thethumbnailattributeisoftheform(width,height,cover_dataas
jpeg).
Returns A
list of f 3-element t tuples.
The list t is s meant t to be e passed to
add_books_to_metadata()(page206).
classmethodadd_books_to_metadata(locations,metadata,booklists)
Addlocationstothebooklists.Thisfunctionmustnotcommunicatewiththedevice.
Parameters
• locations–ResultofacalltoL{upload_books}
• metadata–ListofMetadataobjects,sameasforupload_books()(page206).
• booklists–Atuplecontainingtheresultofcallsto(books(oncard=None)(),
books(oncard=’carda’)(),:meth‘books(oncard=’cardb’)‘).
delete_books(paths,end_session=True)
Deletebooksatpathsondevice.
206
Chapter1. Sections
Documents you may be interested
Documents you may be interested