AlkantarClanX12

Your IP : 3.135.216.196


Current Path : /usr/lib64/python2.7/site-packages/pynche/
Upload File :
Current File : //usr/lib64/python2.7/site-packages/pynche/ColorDB.pyc

�
��^c	@sdZddlZddlZddlTddlZdefd��YZdadZ	dZ
dd3d	��YZd
efd��YZdefd
��YZ
de
fd��YZdefd��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.pytfind_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(RRR+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<red>\d+)\s+(?P<green>\d+)\s+(?P<blue>\d+)\s+(?P<name>.*)(RRtretcompileR(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR<�stHTML40DBcBs eZejd�Zd�ZRS(s+(?P<name>\S+)\s+(?P<hexrgb>#[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?�stLightlinkDBcBs eZejd�Zd�ZRS(s,(?P<name>(.+))\s+(?P<hexrgb>#[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<hexrgb>#[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	tXorgtXConsortiumtHTMLt	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.pytget_colordb�s$		cCs�tj|�}|dkr�|ddkr:t|��n|dd!}|dd!}|dd!}t|d�t|d�t|d�f}|t|<n|S(	s9Converts a #rrggbb color to the tuple (red, green, blue).it#iiiiiN(t	_namedictRR
RR#(tcolorR'RRR((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRA�s


*
cCs6tj|�}|dkr2d|}|t|<n|S(s/Converts a (red, green, blue) tuple to #rrggbb.s
#%02x%02x%02xN(t	_tripdictRR
(R'thexname((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyttriplet_to_rrggbb�s


gp@icCsttj|t�S(N(tmaptoperatort__div__t	_maxtuple(R'((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyttriplet_to_fractional_rgb�scCs6d}d}d}||d||d||dS(Ng�A`��"�?gbX9���?g�v��/�?iii((R'R.R/R0((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyttriplet_to_brightness�st__main__s/usr/openwin/lib/rgb.txts!No parseable color database founditnavyt:sname:saliases:i�i�i�i�i�i�i�sfinding nearest tos...sfound nearest colortintsecondss%20s: (%3d/%3d/%3d) == %s((gp@(gp@gp@gp@(iii�(i�i�i�(i�i�i�(1t__doc__RR=ttypesR_t	ExceptionRR
RPtSPACEt
COMMASPACERR<R?RBRDR>RMRWRYRAR[R]RaRbRcRRStexitttargetR)RRRR'R(RR tjoinR.R/R0ttimett0R,tt1R:tnR;(((s4/usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt<module>sd
e