;ò
ü¯Ac           @   s”  d  Z  d Z d Z y e Wn d d f \ Z Z n Xy| d k Z d k Z d k Z d k Z d k	 Z	 e i
 i e i i e	 i e i ƒ  ƒ d d d g ƒ ƒ d	 k l Z l Z Wn1 y e i i d
 e ƒ Wn e GHn X‚  n Xe i d i e i ƒ d Z e i d ƒ d Z e i ƒ  d Z d „  Z d Z d „  Z d „  Z d „  Z d „  Z e  d j o* y e e i d ƒ Wqe ƒ  qXn d S(   s¹  windows .cur (cursor) to html table displayer and editor

   an attempt to create and edit .cur files online
   born out of desperation when trying to use ImageMagick's 'convert'
   program to convert a cursor file to BMP so I could modify it, then
   change it back to a cursor. it always changed it to a format 1 image
   the same as an .ico file, and IE6 wouldn't accept it as a cursor.
   not saying it can't be done, but i gave up on its?  
    cur2html -- convert a cursor to an html table (and back again?)
    Copyright (C) 2004  John Comeau <jc@jcomeau.com>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    s5   Not all needed libraries found, upgrade or check pathi   i    Ni   s   libs   python(   s   gpls	   jclicenses   %s
iÿÿÿÿs   .c          G   s   t  Sd  S(   N(   s   False(   s   whatever(    (    s   ./cur2html.pys
   DebugPrint6   s    s<   01234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwc    +      G   sÕ  d } y: x) t |  d ƒ t i j o |  d }  q W|  d } Wn
 ‚  n Xy¡ g  } | d j o: t i | ƒ d | j o t	 d ‚ n t
 | d ƒ } n
 t i } y |  d } Wn d } n X| d j o t
 | d ƒ }) n
 t i }) Wn
 ‚  n XyÉ| i | ƒ } | d d	 !} | d
 j o t	 d t | ƒ ‚ n t | d	 ƒ } | d j o t	 d | ‚ n | d j o | i d ƒ n t | d ƒ t | d ƒ f \ } } t d | | ƒ t | d ƒ t | d ƒ f \ } } | d j p
 | d j o | i d | | f ƒ n t | d ƒ t | d ƒ f \ }# }" t d |# |" ƒ t  | d ƒ } t d | ƒ t  | d ƒ } t d | ƒ t  | | ƒ }* |* d j o | i d |* ƒ n t  | | d	 ƒ }& |& | j o t	 d |& | f ‚ n t  | | d ƒ }	 |	 | d j o t	 d |	 | | d f ‚ n t d |& |	 ƒ t | | d ƒ }' t | | d ƒ }! t  | | d  ƒ } | d j o t	 d! | ‚ n t  | | d" ƒ } t d# | ƒ d d d f \ } } } g  } g  } g  } |! d$ j  oˆ xg t0 d d |! d >ƒ D]N } | |* | d	 } | i t3 t | | | d% !ƒ ƒ t d& | | | ƒ qW| |* d |! d >d	 }
 n | |* }
 |! d j o t	 d' ‚ nK|! d j o t	 d( ‚ n1|! d	 j o t	 d) ‚ n|! d j oü t5 | d% d	 ƒ d	 } t d* ƒ } xâ t0 | d d+ d+ ƒ D]¹ } |
 | | } | i g  ƒ xz t3 t | | | | !ƒ D]^ } | o t i: i; d, | ƒ n y | i1 | ƒ Wn | i | ƒ n X| d+ i | ƒ q^W| o t i: i; d- ƒ q"q"Wn t	 d. |! ‚ |
 | | }  t5 | d d% ƒ d	 d	 }( d } t d/ ƒ } xã t0 | d d+ d+ ƒ D]Ë } |  |( | } x™ t0 d | ƒ D]ˆ }% t5 |% d ƒ } t | | | ƒ d0 |% d ?@d0 |% d ?}$ |$ d j o d+ | | d | |% <n | o t i: i; d, |$ ƒ qgqgW| o t i: i; d- ƒ qCqCWt d1 | ƒ t d2 | ƒ x” t0 d tA | ƒ ƒ D]} } xg t0 d tA | | ƒ ƒ D]L }% | | |% } | d+ j o |) i; d3 ƒ qb|) i; tB | i1 | ƒ ƒ qbW|) i; d- ƒ qBWWn
 ‚  n Xd4 S(5   sÂ   convert cursor file to text representation

    looks in argv for input and output filenames
    if no output filename, outputs to stdout
    if input filename is "-", expects input from stdin
 i   i    s   -i   s   file size too larges   rbi   s   wbi   s      s%   not recognizable as a cursor file: %ss   no cursors found in %ss0   more than one cursor found, only using first onei   s   dimensions:i   i	   s0   strange values found for colors/reserved: %d, %di
   i   s   hotspot at:i   s.   size of infoheader + AND bitmap + XOR bitmap: i   s   infoheader starts at offset: i(   s6   proceeding as if header were 40 bytes, though it is %ds/   BMP cursor width %d does not match CUR width %di   s4   wrong scan line count %d for height %d, should be %ds   cursor dimensions:i   s$   cannot deal with compression type %di   s   size of image in bytesi   i   s
   color[%d]:s   bpp=1 not yet implementeds   bpp=2 not yet implementeds   bpp=4 not yet implementeds   pixel map follows:iÿÿÿÿs   %02xs   
s   bpp=%d not yet implementeds   pixelmask map follows:i€   s   colors_used:s   pixels:s    N(C   s   maxsizes   types   argss   typess
   StringTypes   filenames   warningss   oss   stats	   Exceptions   opens
   filehandles   syss   stdins   outfilenames   outfilehandles   stdouts   reads   contentss   magics   reprs   shorts   counts   appends   ords   widths   heights
   DebugPrints   colorss   reserveds   hotspotXs   hotspotYs   longs   bytesizes
   infoheaders
   headersizes   cursorwidths   cursorheights   planess   bitss   compressions	   imagesizes   Rs   Gs   Bs   colors   pixelss   colors_useds   ranges   indexs   offsets   maps	   pixeldatas   ints   rowbytess   dumps   rowstarts   pixels   stderrs   writes   maskdatas	   maskbytess   bitindexs   pixeloffsets   masks   lens   abbreviation(+   s   argss   rowstarts   bitindexs   reserveds   dumps   colors   bytesizes   heights   colorss   cursorheights	   pixeldatas   contentss   colors_useds   indexs   compressions   outfilenames
   infoheaders   filenames   widths   maxsizes
   filehandles   pixels   Bs	   imagesizes   Gs   warningss   Rs   offsets   pixelss   rowbytess   counts   magics   maskdatas   bitss   hotspotYs   hotspotXs   masks   pixeloffsets   cursorwidths   planess	   maskbytess   outfilehandles
   headersize(    (    s   ./cur2html.pys   cur2txt<   s     	
&&& !
    ,  c    '      G   s.  d } y: x) t |  d ƒ t i j o |  d }  q W|  d } Wn
 ‚  n Xy@ g  } t i | ƒ d | j o t	 d ‚ n t
 | d ƒ } Wn
 ‚  n Xyƒ| i ƒ  } | d d !} | d j o t	 d t | ƒ ‚ n t | d ƒ } | d j o t	 d	 | ‚ n | d j o | i d
 ƒ n t | d ƒ t | d ƒ f \ } } t d | | ƒ t | d ƒ t | d ƒ f \ } } | d j p
 | d j o | i d | | f ƒ n t | d ƒ t | d ƒ f \ }  } t d |  | ƒ t | d ƒ } t d | ƒ t | d ƒ } t d | ƒ t | | ƒ }& |& d j o | i d |& ƒ n t | | d ƒ }# |# | j o t	 d |# | f ‚ n t | | d ƒ }	 |	 | d j o t	 d |	 | | d f ‚ n t d |# |	 ƒ t | | d ƒ }$ t | | d ƒ } t | | d ƒ } | d j o t	 d | ‚ n t | | d ƒ } t d  | ƒ d d! d f \ } } } g  } | d" j  oˆ xg t) d d | d! >ƒ D]N } | |& | d } | i t, t | | | d# !ƒ ƒ t d$ | | | ƒ q¢W| |& d | d! >d }
 n | |& }
 | d! j o t	 d% ‚ nó | d j o t	 d& ‚ nÙ | d j o t	 d' ‚ n¿ | d j o¤ t. | d# d ƒ d } t d( ƒ } xŠ t) d | ƒ D]h } |
 | | } | oM x6 t, t | | | | !ƒ D] } t3 i4 i5 d) | ƒ qáWt3 i4 i5 d* ƒ q«q«Wn t	 d+ | ‚ |
 | | } t. | d d# ƒ d d }% d } t d, ƒ } xµ t) d | ƒ D]¤ } | |% | } xr t) d | ƒ D]a }" t. |" d ƒ } t | | | ƒ d- |" d ?@d- |" d ?}! | o t3 i4 i5 d) |! ƒ q˜q˜W| o t3 i4 i5 d* ƒ qtqtWWn
 ‚  n Xd. S(/   sQ   convert cursor file to HTML template

    looks in argv then in CGI parameters"
 i   i    i   s   file size too larges   rbi   s      s%   not recognizable as a cursor file: %ss   no cursors found in %ss0   more than one cursor found, only using first onei   s   dimensions:i   i	   s0   strange values found for colors/reserved: %d, %di
   i   s   hotspot at:i   s.   size of infoheader + AND bitmap + XOR bitmap: i   s   infoheader starts at offset: i(   s6   proceeding as if header were 40 bytes, though it is %ds/   BMP cursor width %d does not match CUR width %di   s4   wrong scan line count %d for height %d, should be %ds   cursor dimensions:i   s$   cannot deal with compression type %di   s   size of image in bytesi   i   i   s
   color[%d]:s   bpp=1 not yet implementeds   bpp=2 not yet implementeds   bpp=4 not yet implementeds   pixel map follows:s   %02xs   
s   bpp=%d not yet implementeds   pixelmask map follows:i€   N(;   s   maxsizes   types   argss   typess
   StringTypes   filenames   warningss   oss   stats	   Exceptions   opens
   filehandles   reads   contentss   magics   reprs   shorts   counts   appends   ords   widths   heights
   DebugPrints   colorss   reserveds   hotspotXs   hotspotYs   longs   bytesizes
   infoheaders
   headersizes   cursorwidths   cursorheights   planess   bitss   compressions	   imagesizes   Rs   Gs   Bs   colors   ranges   indexs   offsets   maps	   pixeldatas   ints   rowbytess   dumps   rowstarts   pixels   syss   stderrs   writes   maskdatas	   maskbytess   bitindexs   pixeloffsets   mask('   s   argss   rowstarts   bitindexs   reserveds   dumps   colors   bytesizes   heights   colorss   cursorheights	   pixeldatas   contentss   indexs   compressions
   infoheaders   filenames   widths   maxsizes
   filehandles   pixels   Bs	   imagesizes   Gs   warningss   Rs   offsets   rowbytess   counts   magics   maskdatas   bitss   hotspotYs   hotspotXs   masks   pixeloffsets   cursorwidths   planess	   maskbytess
   headersize(    (    s   ./cur2html.pys   cur2htmlÐ   sÆ      &&& !
    ,c         C   s$   t  |  d ƒ d t  |  d ƒ Sd S(   s7   convert first two bytes of bytestring to 16-bit integeri    i   i   N(   s   ords
   bytestring(   s
   bytestring(    (    s   ./cur2html.pys   short@  s     c         C   s    t  |  ƒ d t  |  d ƒ Sd S(   s7   convert first 4 bytes of bytestring into 32-bit integeri   i   N(   s   shorts
   bytestring(   s
   bytestring(    (    s   ./cur2html.pys   longD  s     s   __main__(!   s   __doc__s	   Copyrights   errormessages   Trues   Falses   syss   oss   typess   res   pwds   paths   appends   seps   joins   getpwuids   geteuids   com.jcomeaus   gpls	   jclicenses   stderrs   writes   argvs   splits   selfs   commands   originalselfs
   DebugPrints   abbreviations   cur2txts   cur2htmls   shorts   longs   __name__(   s   gpls
   DebugPrints   shorts   Falses	   Copyrights   originalselfs   oss   selfs   errormessages   longs   syss   res   pwds	   jclicenses   commands   abbreviations   cur2htmls   Trues   typess   cur2txt(    (    s   ./cur2html.pys   ?	   s>   -8			”	p		