File: //usr/share/inkscape/extensions/embedimage.pyc
�
��Yc @ s� d Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d e j f d � � YZ e d k r� e � Z
e
j � n d S( s�
Copyright (C) 2005,2007 Aaron Spike, aaron@ekips.org
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
i����Nt Embedderc B s5 e Z d � Z d � Z d � Z d � Z d � Z RS( c
C sE t j j | � | j j d d d d d d d d d t d
d �d S( Ns -ss --selectedonlyt actiont storet typet inkboolt destt selectedonlyt defaultt helps embed only selected images( t inkext Effectt __init__t OptionParsert
add_optiont False( t self( ( s, /usr/share/inkscape/extensions/embedimage.pyR s
c C s9 | j j r% | j | j | j � n | j | j � d S( N( t optionsR t
embedSelectedt documentt selectedt embedAll( R ( ( s, /usr/share/inkscape/extensions/embedimage.pyt effect% s c C sm | | _ | | _ | j j ri xH | j � D]7 \ } } | j t j d d � k r+ | j | � q+ q+ Wn d S( Nt imaget svg( R R R t idst iteritemst tagR t addNSt
embedImage( R R R t idt node( ( s, /usr/share/inkscape/extensions/embedimage.pyR - s c C sL | | _ d } x6 | j j � j | d t j �D] } | j | � q1 Wd S( Ns //svg:imaget
namespaces( R t getroott xpathR t NSSR ( R R t pathR ( ( s, /usr/share/inkscape/extensions/embedimage.pyR 5 s (c
C s� | j t j d d � � } | d k s7 | d d k r�| j t j d d � � } t j | � } t j | j � } d } | d k r� t j j | � } n t j j
| � s� | d k r� | } q� n y t | d � } Wn t k
r� | } n Xt j j
| � s?t j
t d � � | r?t j
t d
� t | � � q?n t j j
| � r�t | d � j � } t } | d d
k r�d } n� | d d k r�d } n� | d d k r�d } np | d d k s�| d d k r�d } nG | d d k s | d d k r d } n | j d � r!d } n t } | r�| j t j d d � d | t j | � f � | d k r�| j t j d d � =q�q�t j
t d � | � q�n d S( Nt hreft xlinki s data:t absreft sodipodit s utf-8ss No xlink:href or sodipodi:absref attributes found, or they do not point to an existing file! Unable to embed image.s Sorry we could not locate %st rbi s �PNGs image/pngi s ��s
image/jpegt BMs image/bmpi t GIF87at GIF89as image/gift MM *s II* s
image/tiffs .icos image/x-icons data:%s;base64,%su sodipodisZ %s is not of type image/png, image/jpeg, image/bmp, image/gif, image/tiff, or image/x-icon( t getR R t Nonet urlparset urllibt url2pathnameR# t ost realpatht isfilet unicodet TypeErrort errormsgt _t strt opent readt Truet endswithR t sett base64t encodestringt attrib(
R R R% R&