File: //usr/share/inkscape/extensions/guillotine.pyc
�
��Yc @ s� d Z d d l Z d d l Z d d l Z y d d l m Z m Z e Z Wn
e Z n Xd d l
Z
d d l Z e j e j
d � d � Z d e
j f d � � YZ e d k r� e � Z e j � n d S( sp
guillotine.py
Copyright (C) 2010 Craig Marshall, craig9 [at] gmail.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-----------------------
This script slices an inkscape drawing along the guides, similarly to
the GIMP plugin called "guillotine". It can optionally export to the
same directory as the SVG file with the same name, but with a number
suffix. e.g.
/home/foo/drawing.svg
will export to:
/home/foo/drawing0.png
/home/foo/drawing1.png
/home/foo/drawing2.png
/home/foo/drawing3.png
etc.
i����N( t Popent PIPEt c C s t t | � t | � � S( s�
This is used to sort the horizontal and vertical guide positions,
which are floating point numbers, but which are held as text.
( t cmpt float( t at b( ( s, /usr/share/inkscape/extensions/guillotine.pyt
float_sort7 s t
Guillotinec B s� e Z d Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d
� Z d � Z
d � Z d
� Z RS( s Exports slices made using guidesc C s� t j j | � | j j d d d d d d d d d d d
�| j j d d d d d d d d d d d
�| j j d
d d d d d d d d d d
�d S( Ns --directoryt actiont storet typet stringt destt directoryt defaultt helpR s --imaget images --ignoret inkboolt ignore( t inkext Effectt __init__t OptionParsert
add_optiont None( t self( ( s, /usr/share/inkscape/extensions/guillotine.pyR @ s
c C s� | j j � } g } | j j d d t j �} x� | D]� } i } | j d j d � \ } } | j d d d k r� d | d <| | d <| j | � q7 | j d d d
k r7 d | d <| | d <| j | � q7 q7 W| S( sF
Returns all guide elements as an iterable collection
s //sodipodi:guidet
namespacest positiont ,t orientationi s 0,t
horizontali����s ,0t vertical( t documentt getroott xpathR t NSSt attribt splitt append( R t roott guidesR# t gt guidet xt y( ( s, /usr/share/inkscape/extensions/guillotine.pyt
get_guidesN s
c C sE g } x8 | j � D]* } | d d k r | j | d � q q W| S( s�
Returns all horizontal guides as a list of floats stored as
strings. Each value is the position from 0 in pixels.
R R R ( R. R'