;ò œbYFc@sìdZdkZdkZdkZdkZydkZd„ZWn%ej odkZd„ZnXdk Z dk Z dk Z d„Z d„Z d„Zd„Zeed„Zd „Zd fd „ƒYZd efd „ƒYZdS(s¯Interface to the thumbnail spec. This provides a functions to look up thumbnails for files and a class which you can extend to generate a thumbnail image for a type of file. NcCsti|ƒiƒSdS(N(shashlibsmd5sss hexdigest(ss((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysmd5hash scCsti|ƒiƒSdS(N(smd5snewsss hexdigest(ss((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysmd5hashscCs7tii|ƒ}dti|ƒ}t|ƒdSdS(Nsfile://s.png(sosspathsabspathsfnamesroxsescapesurismd5hash(sfnamesurispath((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys_leafscCsgt|ƒ}xTddfD]F}tiitidd||ƒ}ti|ti ƒo|SqqWdS(suGiven a file name return the full path of an existing thumbnail image. If no thumbnail image exists, return NonesnormalslargesHOMEs .thumbnailsN( s_leafsfnamesleafssdirsosspathsjoinsenvironsaccesssR_OK(sfnamesleafssdirspath((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysget_paths   cCs0t|ƒ}tiitiddd|ƒSdS(sXGiven a file name return the full path of the location to store the thumbnail image.sHOMEs .thumbnailssnormalN(s_leafsfnamesleafsosspathsjoinsenviron(sfnamesleaf((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys get_path_save&s cCs¹t|ƒ}|o+ytiii|ƒ}Wq>tSq>Xnt |i dƒƒ}t |i dƒƒ}ti|ƒ}|t |iƒjpt |ƒt |iƒjotSn|SdS(srGiven a file name return a GdkPixbuf of the thumbnail for that file. If no thumbnail image exists return None.stEXt::Thumb::SizestEXt::Thumb::MTimeN(sget_pathsfnamespathsroxsgsgdkspixbuf_new_from_filespbufsNonesints get_optionstsizesfloatstmtimesossstatsssst_sizesst_mtime(sfnamespbufstsizestmtimessspath((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys get_image,s  2cCs|otii|ƒ}nt|tƒotii|ƒ}n| otSnti i ddd|i |i fƒ}|o/ti|ƒotii|dƒSn|SnxJtiiiƒD]6}x-|dD]!}|t|ƒjotSqÕqÕWqÄWtSdS(sVLook up the program for generating a thumbnail. Specify either a path to a file or a MIME type. This returns False if there is no defined method to generate the thumbnail, True if the thumbnail would be generated internally using GdkPixbuf, or a string giving the full path to a program called to generate the thumbnail.srox.sourceforge.nets MIME-thumbs%s_%ssAppRuns mime_typesN(spathsroxsmimesget_typesmtypes isinstances basestringslookupsFalsesbasedirsload_first_configsmediassubtypesmthdsisappdirsossjoinsgsgdkspixbuf_get_formatssfmtstsstrsTrue(spathsmtypesfmtsmthdst((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys get_method@s*  cCs‚t|ƒ}| otSn|tjotƒ}|i|ƒdSnt|ƒ}d}t i t i ||||t|ƒƒSdS(sÎGenerate the thumbnail for a file. If a generator for the type of path is not available then None is returned, otherwise an integer which is the exit code of the generation process (0 for success).ii`N(s get_methodspathsmethodsNonesTruesGdkPixbufThumbnailersthsruns get_path_savesoutnamessizesossspawnlsP_WAITsstr(spathsoutnamesthsmethodssize((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysgeneratebs     s ThumbnailercBsktZdZeed„Zedd„Zd„Zd„Zd„Z d„Z d„Z d „Z d „Z RS( sBase class for programs which generate thumbnails. The method run() creates the thumbnail for a source file. This calls the methods get_image(), process_image() and store_image(). process_image() takes the image returned by get_image() and scales it to the correct dimensions then passes it through post_process_image() (which does nothing). You should override the method get_image() to create the image. You can also override post_process_image() if you wish to work on the scaled image.cCs(||_||_||_||_dS(sInitialise the thumbnailer. name - name of the program fname - a string to use in generated temp file names use_wdir - if true then use a temp directory to store files debug - if false then suppress most error messages N(snamesselfsfnamesuse_wdirsdebug(sselfsnamesfnamesuse_wdirsdebug((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys__init__…s    i`cCsã| ot|ƒ}n+tii|ƒ otii|ƒ}n|io|i ƒnyY|i ||ƒ}|i ƒ}|iƒ}|i||ƒ}|i|||||ƒWn|iƒnX|io|iƒndS(sÓGenerate the thumbnail from the file inname - source file outname - path to store thumbnail image, or None for default location rsize - maximum size of thumbnail (in either axis) N(soutnames get_path_savesinnamesosspathsisabssabspathsselfsuse_wdirsmake_working_dirs get_imagesrsizesimgs get_widthsows get_heightsohs process_images store_imagesreport_exceptionsremove_working_dir(sselfsinnamesoutnamesrsizesimgsohsow((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysrun‘s"    cCstdƒ‚dS(s:Method you must define for your thumbnailer to do anythingsThumbnail not implementedN(s_(sselfsinnamesrsize((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys get_image­scCsÈ|iƒ}|iƒ}||jot|ƒt|ƒ}nt|ƒt|ƒ}t||ƒ}t||ƒ}||jp ||jo"|i ||t i iiƒ}n|i|||ƒSdS(sTake the raw image and scale it to the correct size. Returns the result of scaling img and passing it to post_process_image()N(simgs get_widthsows get_heightsohsfloatsrsizesssintswshs scale_simplesroxsgsgdksINTERP_BILINEARsselfspost_process_image(sselfsimgsrsizesohshsowsssw((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys process_image±s   "cCs|SdS(sÙPerform some post-processing on the image. img - gdk-pixbuf of the image w - width h - height Return: modified image The default implementation just returns the image unchanged.N(simg(sselfsimgswsh((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pyspost_process_imageÃsc Cs±ti|ƒ}|i||idhdt |ƒ<dt |ƒ<dt |i ƒ<dt |i ƒ<dtid|ƒ<d|i<ƒti||i|ƒ||_d S( spStore the thumbnail image it the correct location, adding the extra data required by the thumbnail spec.spngstEXt::Thumb::Image::WidthstEXt::Thumb::Image::HeightstEXt::Thumb::SizestEXt::Thumb::MTimestEXt::Thumb::URIsfile://stEXt::SoftwareN(sossstatsinnamesssimgssavesoutnamesselfsfnamesstrsowsohsst_sizesst_mtimesroxsescapesnamesrenamescreated(sselfsimgsinnamesoutnamesowsohss((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys store_imageÌs kcCsWytiƒ|_Wn|iƒt|_dSnXtiƒ|_ti |iƒdS(s2Create the temporary directory and change into it.N( stempfilesmkdtempsselfswork_dirsreport_exceptionsNonesossgetcwdsold_dirschdir(sself((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysmake_working_dirÛs  cCsX|i odSnti|iƒyti|iƒWn|iƒnXt|_dS(sORemove our temporary directory, after changing back to the previous oneN( sselfswork_dirsosschdirsold_dirsshutilsrmtreesreport_exceptionsNone(sself((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysremove_working_dirçs cCs&|idjodSntiƒdS(s9Report an exception if debug enabled, otherwise ignore itiN(sselfsdebugsroxsreport_exception(sself((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysreport_exceptionõs(s__name__s __module__s__doc__sFalses__init__sNonesruns get_images process_imagespost_process_images store_imagesmake_working_dirsremove_working_dirsreport_exception(((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys Thumbnailerxs      sGdkPixbufThumbnailercBs tZdZd„Zd„ZRS(soAn example implementation of a Thumbnailer class. It uses GdkPixbuf to generate thumbnails of image files.cCsti|ddttƒdS(NsGdkPixbufThumbnailerspixbuf(s Thumbnailers__init__sselfsFalse(sself((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys__init__ÿscCsRttiidƒotiii|||ƒ}ntiii|ƒ}|SdS(Nspixbuf_new_from_file_at_size( shasattrsroxsgsgdkspixbuf_new_from_file_at_sizesinnamesrsizesimgspixbuf_new_from_file(sselfsinnamesrsizesimg((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys get_images(s__name__s __module__s__doc__s__init__s get_image(((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pysGdkPixbufThumbnailerûs  (s__doc__sosssysstempfilesshutilshashlibsmd5hashs ImportErrorsmd5sroxs rox.basedirsrox.mimes_leafsget_paths get_path_saves get_imagesNones get_methodsgenerates ThumbnailersGdkPixbufThumbnailer(sroxshashlibs get_path_savestempfiles_leafsmd5hashsget_pathssyss Thumbnailers get_imagesGdkPixbufThumbnailersshutilsossgenerates get_methodsmd5((sW/mnt/gmirror/ports/devel/py-roxlib/work/rox-lib2-2.0.5/ROX-Lib2/python/rox/thumbnail.pys?s$        " ƒ