ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     ÿØÿà JFIF      ÿÛ „ 	 ( %!1!%)+//.383,7(-.+



-%%-////---/-.+/--+------/------/--0+--/-/-----.-----ÿÀ  ¥2" ÿÄ               ÿÄ J  	     ! 1AQ"aq2‘#BR‚¡ÁÑ3br’¢±Âð$CSƒ²á4c“%DsÓñÿÄ              ÿÄ *        !1AQa‘"2q3±ð#b¡ÿÚ   ? ¼QxJQaÍuò¸Zö Úü8,ÐÚú
"SSn<rçù–´âE—^ªBÖ9À\†¸ÔÁT­ÃÛ5
ëd´³Í#Ý;Þ38œî ¶H£M:wÎ3…³…âpÔF&‚FK¸9„â4àGEõªfÿ ‘ñ(ßw­pŽF|È¥ù®häðÍÑ¶¹‘[ÒinÙW¶ùñY˜Q{›K"išÒ[Ú8žë\F¹@-?v"ÔU”,ìöžkÿ {I‡£šÍ?e
ríV
..............................................................................................................................................................................
.............................................................................                                                  
                                                                                                                                                                                     
^c        	   @   s  d  Z  d d l Z d d l Z d d l Td d l Z d e f d     YZ d a d Z	 d Z
 d d3 d	     YZ d
 e f d     YZ d e f d     YZ d e f d     YZ d e f d     YZ e j d  e f e j d  e f e j d  e f e j d  e f e j d  e f g Z d d  Z i  Z d   Z i  a d   Z d5 Z d   Z d   Z e d k re d  Z e sd  GHe j d!  n  d" Z e j e  \ Z Z  Z! Z" e Gd# Ge Ge  Ge! Ge e"  GHe j# e"  \ Z$ Z% d$ Ge$ Gd% Ge
 j& e%  GHd6 \ Z' Z( Z) d7 \ Z' Z( Z) d8 \ Z' Z( Z) d- Ge Gd. GHd d l* Z* e* j*   Z+ e j, e' e( e)  Z, e* j*   Z- d/ Ge, Gd0 Ge- e+ Gd1 GHxi e j.   D]X Z/ e j e/  \ Z' Z( Z) e j0 e' e( e)  Z% d2 e/ e' e( e) e	 j& e% d!  f GHqWn  d S(9   sG  Color 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.

iN(   t   *t   BadColorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR      s   t    s   , t   ColorDBc           B   sY   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 RS(	   c         C   sA  d } | j  |  _ i  |  _ i  |  _ d  |  _ x| D]} |  j j |  } | s t j	 d I| j  Id I| IJ| d 7} q4 n  |  j
 |  \ } } } |  j |  } | j   }	 | | | f }
 |  j j |
 | g  f  \ } } | | k r| | k r| j |  n  | | f |  j |
 <|
 |  j |	 <| d } q4 Wd  S(   Ni   s   Error ins    linei   (   t   namet   _ColorDB__namet   _ColorDB__byrgbt   _ColorDB__bynamet   Nonet   _ColorDB__allnamest   _ret   matcht   syst   stderrt   _extractrgbt   _extractnamet   lowert   gett   append(   t   selft   fpt   linenot   linet   mot   redt   greent   blueR   t   keynamet   keyt	   foundnamet   aliases(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   __init__'   s*    			"
!c         C   s,   g  | j  d d d  D] } t |  ^ q S(   NR   R   R   (   t   groupt   int(   R   R   t   x(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR   M   s    c         C   s   | j  d  S(   NR   (   R"   (   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR   P   s    c         C   s   |  j  S(   N(   R   (   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   filenameS   s    c         C   s3   y |  j  | SWn t k
 r. t |   n Xd S(   s   Return name for rgbtupleN(   R   t   KeyErrorR   (   R   t   rgbtuple(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt
   find_byrgbV   s    c         C   s?   | j    } y |  j | SWn t k
 r: t |   n Xd S(   s"   Return (red, green, blue) for nameN(   R   R	   R&   R   (   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   find_byname]   s
    c         C   s   d } d } x |  j  j   D] \ } } |  j | j   \ } }	 }
 | | } | |	 } | |
 } | | | | | | } | d k s | | k  r | } | } q q W| S(   s3   Return the name of color nearest (red, green, blue)it    (   R   t   valuesR	   R   (   R   R   R   R   t   nearestt   nearest_nameR   R    t   rt   gt   bt   rdeltat   gdeltat   bdeltat   distance(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR,   e   s    


c         C   se   |  j  s^ g  |  _  x- |  j j   D] \ } } |  j  j |  q" Wd   } |  j  j |  n  |  j  S(   Nc         S   s   t  |  j   | j    S(   N(   t   cmpR   (   t   n1t   n2(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt
   nocase_cmp~   s    (   R   R   R+   R   t   sort(   R   R   R    R8   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   unique_namesw   s    			c         C   sT   y  |  j  | | | f \ } } Wn& t k
 rH t | | | f   n X| g | S(   N(   R   R&   R   (   R   R   R   R   R   R    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt
   aliases_of   s
     (   R   R   R!   R   R   R%   R(   R)   R,   R:   R;   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR   &   s   	&							t
   RGBColorDBc           B   s   e  Z e j d   Z RS(   s?   \s*(?P<red>\d+)\s+(?P<green>\d+)\s+(?P<blue>\d+)\s+(?P<name>.*)(   R   R   t   ret   compileR   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR<      s   t   HTML40DBc           B   s    e  Z e j d   Z d   Z RS(   s+   (?P<name>\S+)\s+(?P<hexrgb>#[0-9a-fA-F]{6})c         C   s   t  | j d   S(   Nt   hexrgb(   t   rrggbb_to_tripletR"   (   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR      s    (   R   R   R=   R>   R   R   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR?      s   t   LightlinkDBc           B   s    e  Z e j d   Z d   Z RS(   s,   (?P<name>(.+))\s+(?P<hexrgb>#[0-9a-fA-F]{6})c         C   s   | j  d  j   S(   NR   (   R"   t   strip(   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR      s    (   R   R   R=   R>   R   R   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRB      s   t	   WebsafeDBc           B   s)   e  Z e j d   Z d   Z d   Z RS(   s   (?P<hexrgb>#[0-9a-fA-F]{6})c         C   s   t  | j d   S(   NR@   (   RA   R"   (   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR      s    c         C   s   | j  d  j   S(   NR@   (   R"   t   upper(   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyR      s    (   R   R   R=   R>   R   R   R   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRD      s   	t   Xorgt   XConsortiumt   HTMLt	   lightlinkt   Websafec   	      C   s   d  } t |   } zx | j   } | s+ d  S| d  k r@ t } n	 | g } x1 | D]% \ } } | j |  } | rP PqP qP Wd  S| |  } Wd  | j   X| a | S(   N(   R
   t   opent   readlinet	   FILETYPESt   searcht   closet
   DEFAULT_DB(	   t   filet   filetypet   colordbR   R   t	   filetypest   typeret   class_R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   get_colordb   s$    		c         C   s   t  j |   } | d k r |  d d k r: t |    n  |  d d !} |  d d !} |  d d !} t | d  t | d  t | d  f } | t  |  <n  | S(	   s9   Converts a #rrggbb color to the tuple (red, green, blue).i    t   #i   i   i   i   i   N(   t	   _namedictR   R
   R   R#   (   t   colorR'   R   R   R   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyRA      s    *c         C   s6   t  j |   } | d k r2 d |  } | t  |  <n  | S(   s/   Converts a (red, green, blue) tuple to #rrggbb.s   #%02x%02x%02xN(   t	   _tripdictR   R
   (   R'   t   hexname(    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   triplet_to_rrggbb   s
    
g      p@i   c         C   s   t  t j |  t  S(   N(   t   mapt   operatort   __div__t	   _maxtuple(   R'   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   triplet_to_fractional_rgb   s    c         C   s6   d } d } d } | |  d | |  d | |  d S(   NgA`"?gbX9?gv/?i    i   i   (    (   R'   R.   R/   R0   (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   triplet_to_brightness   s    t   __main__s   /usr/openwin/lib/rgb.txts!   No parseable color database foundi   t   navyt   :s   name:s   aliases:i   i   i   i   i   i   i   s   finding nearest tos   ...s   found nearest colort   int   secondss   %20s: (%3d/%3d/%3d) == %s(    (   g      p@(   g      p@g      p@g      p@(   i   i   i   (   i   i   i   (   i   i   i   (1   t   __doc__R   R=   t   typesR_   t	   ExceptionR   R
   RP   t   SPACEt
   COMMASPACER   R<   R?   RB   RD   R>   RM   RW   RY   RA   R[   R]   Ra   Rb   Rc   R   RS   t   exitt   targetR)   R   R   R   R'   R(   R   R    t   joinR.   R/   R0   t   timet   t0R,   t   t1R:   t   nR;   (    (    (    s4   /usr/lib64/python2.7/site-packages/pynche/ColorDB.pyt   <module>   sd   
e		
		
