ó ¿œ^c @sdZddlZddlZddlTddlZdefd„ƒYZdadZ dZ dd3d „ƒYZ d e fd „ƒYZ d e fd „ƒYZ de fd„ƒYZde fd„ƒYZejdƒe fejdƒe fejdƒe fejdƒefejdƒefgZdd„ZiZd„Ziad„Zd5Zd„Zd„ZedkredƒZesœd GHejd!ƒnd"Zejeƒ\ZZ Z!Z"eGd#GeGe Ge!Gee"ƒGHej#e"ƒ\Z$Z%d$Ge$Gd%Ge j&e%ƒGHd6\Z'Z(Z)d7\Z'Z(Z)d8\Z'Z(Z)d-GeGd.GHddl*Z*e*j*ƒZ+ej,e'e(e)ƒZ,e*j*ƒZ-d/Ge,Gd0Ge-e+Gd1GHxiej.ƒD]XZ/eje/ƒ\Z'Z(Z)ej0e'e(e)ƒZ%d2e/e'e(e)e j&e%d!ƒfGHq¥WndS(9sGColor Database. This file contains one class, called ColorDB, and several utility functions. The class must be instantiated by the get_colordb() function in this file, passing it a filename to read a database out of. The get_colordb() function will try to examine the file to figure out what the format of the file is. If it can't figure out the file format, or it has trouble reading the file, None is returned. You can pass get_colordb() an optional filetype argument. Supporte file types are: X_RGB_TXT -- X Consortium rgb.txt format files. Three columns of numbers from 0 .. 255 separated by whitespace. Arbitrary trailing columns used as the color name. The utility functions are useful for converting between the various expected color formats, and for calculating other color values. iÿÿÿÿN(t*tBadColorcBseZRS((t__name__t __module__(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRst s, tColorDBcBsYeZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d„Z RS( c CsAd}|j|_i|_i|_d|_x |D]}|jj|ƒ}|s„tj dI|jIdI|IJ|d7}q4n|j |ƒ\}}}|j |ƒ}|j ƒ} |||f} |jj | |gfƒ\} } | |kr| | kr| j|ƒn| | f|j| <| |j| <|d}q4WdS(NisError ins linei(tnamet_ColorDB__namet_ColorDB__byrgbt_ColorDB__bynametNonet_ColorDB__allnamest_retmatchtsyststderrt _extractrgbt _extractnametlowertgettappend( tselftfptlinenotlinetmotredtgreentblueRtkeynametkeyt foundnametaliases((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt__init__'s*     "  ! cCs,g|jdddƒD]}t|ƒ^qS(NRRR(tgrouptint(RRtx((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRMscCs |jdƒS(NR(R"(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRPscCs|jS(N(R(R((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pytfilenameSscCs3y|j|SWntk r.t|ƒ‚nXdS(sReturn name for rgbtupleN(RtKeyErrorR(Rtrgbtuple((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt find_byrgbVs cCs?|jƒ}y|j|SWntk r:t|ƒ‚nXdS(s"Return (red, green, blue) for nameN(RR R&R(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt find_byname]s   cCs«d}d}x˜|jjƒD]‡\}}|j|jƒ\}} } ||} || } || } | | | | | | }|dks”||kr|}|}qqW|S(s3Return the name of color nearest (red, green, blue)iÿÿÿÿt(RtvaluesR R(RRRRtnearestt nearest_nameRR trtgtbtrdeltatgdeltatbdeltatdistance((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR,es    cCse|js^g|_x-|jjƒD]\}}|jj|ƒq"Wd„}|jj|ƒn|jS(NcSst|jƒ|jƒƒS(N(tcmpR(tn1tn2((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt nocase_cmp~s(R RR+Rtsort(RRR R8((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt unique_namesws   cCsTy |j|||f\}}Wn&tk rHt|||fƒ‚nX|g|S(N(RR&R(RRRRRR ((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt aliases_ofƒs   ( RRR!RRR%R(R)R,R:R;(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR&s &       t RGBColorDBcBseZejdƒZRS(s?\s*(?P\d+)\s+(?P\d+)\s+(?P\d+)\s+(?P.*)(RRtretcompileR (((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR<‹stHTML40DBcBs eZejdƒZd„ZRS(s+(?P\S+)\s+(?P#[0-9a-fA-F]{6})cCst|jdƒƒS(Nthexrgb(trrggbb_to_tripletR"(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR“s(RRR=R>R R(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR?st LightlinkDBcBs eZejdƒZd„ZRS(s,(?P(.+))\s+(?P#[0-9a-fA-F]{6})cCs|jdƒjƒS(NR(R"tstrip(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR™s(RRR=R>R R(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRB–st WebsafeDBcBs)eZejdƒZd„Zd„ZRS(s(?P#[0-9a-fA-F]{6})cCst|jdƒƒS(NR@(RAR"(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRŸscCs|jdƒjƒS(NR@(R"tupper(RR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR¢s(RRR=R>R RR(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRDœs tXorgt XConsortiumtHTMLt lightlinktWebsafec Cs¢d}t|ƒ}zx|jƒ}|s+dS|dkr@t}n |g}x1|D]%\}}|j|ƒ}|rPPqPqPWdS||ƒ}Wd|jƒX|a|S(N(R topentreadlinet FILETYPEStsearchtcloset DEFAULT_DB( tfiletfiletypetcolordbRRt filetypesttyperetclass_R((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt get_colordb³s$      cCsœtj|ƒ}|dkr˜|ddkr:t|ƒ‚n|dd!}|dd!}|dd!}t|dƒt|dƒt|dƒf}|t|RMRWRYRAR[R]RaRbRcRRStexitttargetR)RRRR'R(RR tjoinR.R/R0ttimett0R,tt1R:tnR;(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pytsd    e