MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/2/cwd/usr/lib/python2.4/site-packages/pynche/ColorDB.pyc
mò
‚=5Dc	@sdZdkZdkZdkTdkZdefd„ƒYZdadZ	dZ
dfd„ƒYZd	efd
„ƒYZdefd„ƒYZ
d
e
fd„ƒYZdefd„ƒYZeidƒefeidƒefeidƒe
feidƒefeidƒefgZdd„ZhZd„Zhad„Zd2dZd„Zd„ZedjoedƒZepdGHeid ƒnd!Zeieƒ\ZZ Z!Z"eGd"GeGe Ge!Gee"ƒGHei#e"ƒ\Z$Z%d#Ge$Gd$Ge
i&e%ƒGHd3\Z'Z(Z)d4\Z'Z(Z)d5\Z'Z(Z)d,GeGd-GHdk*Z*e*i*ƒZ+ei,e'e(e)ƒZ,e*i*ƒZ-d.Ge,Gd/Ge-e+Gd0GHxjei.ƒD]XZ/eie/ƒ\Z'Z(Z)ei0e'e(e)ƒZ%d1e/e'e(e)e	i&e%d ƒfGHqWndS(6sGColor 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.

N(t*tBadColorcBstZRS(N(t__name__t
__module__(((t2/usr/lib/python2.4/site-packages/pynche/ColorDB.pyRst s, tColorDBcBsYtZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z	d	„Z
RS(
Nc
CsUd}|i|_h|_h|_d|_x!|i	ƒ}
|
pPn|ii|
ƒ}|p3tidI|iIdI|IJ|d7}q0n|i|ƒ\}}}|i|ƒ}|iƒ}|||f}	|ii|	|gfƒ\}}||jo||jo|i|ƒn||f|i|	<|	|i|<|d}q0WdS(NiisError ins line(tlinenotfptnametselft_ColorDB__namet_ColorDB__byrgbt_ColorDB__bynametNonet_ColorDB__allnamestreadlinetlinet_retmatchtmotsyststderrt_extractrgbtredtgreentbluet_extractnametlowertkeynametkeytgett	foundnametaliasestappend(
R
RRR	RR RRRRRRR!((Rt__init__'s2			"
!
cCs4g}|idddƒD]}|t|ƒq~S(NRRR(t_[1]Rtgrouptxtint(R
RR$R&((RRPscCs
|idƒS(NR	(RR%(R
R((RRSscCs|iS(N(R
R(R
((RtfilenameVscCs5y|i|SWntj
ot|ƒ‚nXdS(sReturn name for rgbtupleN(R
RtrgbtupletKeyErrorR(R
R)((Rt
find_byrgbYs
cCsA|iƒ}y|i|SWntj
ot|ƒ‚nXdS(s"Return (red, green, blue) for nameN(R	RR
R
R*R(R
R	((Rtfind_byname`scCs®d}d}x›|iiƒD]Š\}}|i|iƒ\}	}}||	}||}
||}
|||
|
|
|
}|djp
||jo|}|}qqW|S(s3Return the name of color nearest (red, green, blue)iÿÿÿÿtN(tnearesttnearest_nameR
RtvaluesR	R!R
RtrtgtbRtrdeltaRtgdeltaRtbdeltatdistance(R
RRRR.R3R	R2R7R1R6R/R4R5R!((RR.hs


cCsg|ipVg|_x-|iiƒD]\}}|ii|ƒq#Wd„}|ii|ƒn|iS(NcCst|iƒ|iƒƒS(N(tcmptn1Rtn2(R9R:((Rt
nocase_cmps(	R
RRR0R	R!R"R;tsort(R
R;R	R!((Rtunique_nameszs
		cCsVy |i|||f\}}Wn(tj
ot|||fƒ‚nX|g|S(N(	R
RRRRR	R!R*R(R
RRRR	R!((Rt
aliases_of†s
 (RRR#RRR(R+R,R.R=R>(((RR&s	)							t
RGBColorDBcBstZeidƒZRS(Ns?\s*(?P<red>\d+)\s+(?P<green>\d+)\s+(?P<blue>\d+)\s+(?P<name>.*)(RRtretcompileR(((RR?ŽstHTML40DBcBs tZeidƒZd„ZRS(Ns+(?P<name>\S+)\s+(?P<hexrgb>#[0-9a-fA-F]{6})cCst|idƒƒS(Nthexrgb(trrggbb_to_tripletRR%(R
R((RR–s(RRR@RARR(((RRB“stLightlinkDBcBs tZeidƒZd„ZRS(Ns,(?P<name>(.+))\s+(?P<hexrgb>#[0-9a-fA-F]{6})cCs|idƒiƒS(NR	(RR%tstrip(R
R((RRœs(RRR@RARR(((RRE™st	WebsafeDBcBs)tZeidƒZd„Zd„ZRS(Ns(?P<hexrgb>#[0-9a-fA-F]{6})cCst|idƒƒS(NRC(RDRR%(R
R((RR¢scCs|idƒiƒS(NRC(RR%tupper(R
R((RR¥s(RRR@RARRR(((RRGŸs	tXorgtXConsortiumtHTMLt	lightlinktWebsafec	Cs«d}t|ƒ}z|iƒ}|pdSn|djo
t}n
|g}x3|D]'\}}|i|ƒ}|oPqWqWWdS||ƒ}Wd|iƒX|a|S(N(RtcolordbtopentfileRRRtfiletypet	FILETYPESt	filetypesttyperetclass_tsearchRtcloset
DEFAULT_DB(	RPRQRRURSRNRTRR((Rtget_colordb¶s*

		cCs ti|ƒ}|djo€|ddjot|ƒ‚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	_namedictRtcolorR)RRRRRR'(R\RRR)R((RRDÖs



*cCs8ti|ƒ}|djod|}|t|<n|S(s/Converts a (red, green, blue) tuple to #rrggbb.s
#%02x%02x%02xN(t	_tripdictRR)thexnameR(R)R^((Rttriplet_to_rrggbbås

f256.0icCstti|tƒS(N(tmaptoperatort__div__R)t	_maxtuple(R)((Rttriplet_to_fractional_rgbðscCs6d}d}d}||d||d||dS(Nf0.29899999999999999f0.58699999999999997f0.114iii(R1R2R3R)(R)R1R3R2((Rttriplet_to_brightnessôst__main__s/usr/openwin/lib/rgb.txts!No parseable color database founditnavyt:sname:saliases:i€i‘iîiiÿiûiúsfinding nearest tos...sfound nearest colortintsecondss%20s: (%3d/%3d/%3d) == %s(f256.0(iii€(i‘iîi(iÿiûiú(1t__doc__RR@ttypesRat	ExceptionRRRXtSPACEt
COMMASPACERR?RBRERGRARRRYR[RDR]R_RcRdReRRNtexitttargetR,RRRR)R+R	R!tjoinR1R2R3ttimett0R.tt1R=tnR>(#RYR.RDRaR)RRR!RR?RNRBRR@RvRER[RnRsRRGRReR	R_R3RqR2RtRuR1RRRdRcRo((Rt?s\			h`