HEX
Server: Apache
System: Linux opal14.opalstack.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
User: curbgloabal_opal (1234)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/share/inkscape/extensions/inkex.pyo
�
��Yc@sddZddlZddlZddlZddlZddlZddlZddlZddlTi	dd6dd6dd	6d
d6dd
6dd6dd6dd6dd6Z	d�Z
d�Zd�Zd�Z
yddlmZWn;ek
rZe
�eedef��ej�nXd�Zdd�Zdejfd��YZd d"d!��YZdS(#s�
inkex.py
A helper module for creating Inkscape extensions

Copyright (C) 2005,2010 Aaron Spike <aaron@ekips.org> and contributors

Contributors:
  Aurélio A. Heckert <aurium(a)gmail.com>
  Bulia Byak <buliabyak@users.sf.net>
  Nicolas Dufour, nicoduf@yahoo.fr
  Peter J. R. Moulder <pjrm@users.sourceforge.net>

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����N(t*u2http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtdusodipodiuhttp://creativecommons.org/ns#uccuhttp://web.resource.org/cc/uccOLDuhttp://www.w3.org/2000/svgusvgu http://purl.org/dc/elements/1.1/udcu+http://www.w3.org/1999/02/22-rdf-syntax-ns#urdfu+http://www.inkscape.org/namespaces/inkscapeuinkscapeuhttp://www.w3.org/1999/xlinkuxlinku$http://www.w3.org/XML/1998/namespaceuxmlcCs�d}tjjd�r�ddl}|j�\}}|tjd<y/tjd}tj|||gdt	�}Wq�t
k
r�tj|dt	�}q�Xn�tjjd�rBy)tjd}tj||dt	�}Wq�t
k
r>y)tjd}tj||dt	�}Wq?t
k
r:tj|dt	�}q?Xq�XnRy)tjd}tj||dt	�}Wn&t
k
r�tj|dt	�}nX|j�dS(	Ntinkscapetwini����tLANGtINKSCAPE_LOCALEDIRtfallbacktdarwintPACKAGE_LOCALE_DIR(tsystplatformt
startswithtlocaletgetdefaultlocaletostenvirontgettextttranslationtTruetKeyErrortinstall(tdomainRtcurrent_localetencodingtlocaldirttrans((s'/usr/share/inkscape/extensions/inkex.pytlocalize4s4

"




 

cCstjjt|�d�|S(Ns
(Rtstderrtwritetstr(twhat((s'/usr/share/inkscape/extensions/inkex.pytdebugSscCs_t|t�r/tjj|jd�d�n,tjjt|ddd�djd��dS(s�Intended for end-user-visible error messages.
    
       (Currently just writes to stderr with an appended newline, but could do
       something better in future: e.g. could add markup to distinguish error
       messages from status messages or debugging output.)
      
       Note that this should always be combined with translation:

         import inkex
         ...
         inkex.errormsg(_("This extension requires two selected paths."))
    sutf-8s
terrorstreplaceN(t
isinstancetunicodeRRRtencode(tmsg((s'/usr/share/inkscape/extensions/inkex.pyterrormsgXs
 cCs'||||ko&||||kS(N((tatbteps((s'/usr/share/inkscape/extensions/inkex.pytare_near_relativeks(tetrees.The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension.Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml

Technical details:
%scCsUt|�j�dkrtSt|�j�dkr8tStjd||f��dS(NRtFalses$option %s: invalid inkbool value: %s(Rt
capitalizeRR+toptparsetOptionValueError(toptiontopttvalue((s'/usr/share/inkscape/extensions/inkex.pyt
check_inkbool{s
cCsm|}|dk	rit|�dkri|tkrit|�dkri|ddkridt||f}n|S(Nit{s{%s}%s(tNonetlentNSS(ttagtnstval((s'/usr/share/inkscape/extensions/inkex.pytaddNS�sLt	InkOptioncBs7eZejjdZejejj�Zeed<RS(tinkbool(R<(t__name__t
__module__R-tOptiontTYPEStcopytTYPE_CHECKERR2(((s'/usr/share/inkscape/extensions/inkex.pyR;�stEffectcBs4eZdZd�Zd�Zejdd�Zd+d�Z	d�Z
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zejded�Zed�Zd�Zi
dd6dd6dd6dd6dd6dd6dd6dd 6d!d"6d#d$6Zd%�Zd&�Zd'�Zd(�Zd)�Zd*�ZRS(,s)A class for creating Inkscape SVG EffectscOs�d|_d|_d|_i|_i|_d|_d|_tj	dddt
�|_	|j	jdddddd	d
dgdd
�|j	jdddddd	ddgdd�dS(Ntusagesusage: %prog [options] SVGfiletoption_classs--idtactiontappendttypetstringtdesttidstdefaultthelps$id attribute of object to manipulates--selected-nodestselected_nodess-id:subpath:position of selected nodes, if any(R4tdocumenttoriginal_documenttctxtselectedtdoc_idstoptionstargsR-tOptionParserR;t
add_option(tselfRUtkwargs((s'/usr/share/inkscape/extensions/inkex.pyt__init__�s							cCsdS(s�Apply some effects on the document. Extensions subclassing Effect
        must override this function and define the transformations
        in it.N((RX((s'/usr/share/inkscape/extensions/inkex.pyteffect�sicCs"|jj|�\|_|_dS(sCollect command line argumentsN(RVt
parse_argsRTRU(RXRU((s'/usr/share/inkscape/extensions/inkex.pyt
getoptions�scCs|dk	rTyt|d�}Wq�tk
rPttd�|�tj�q�Xnf|jdk	r�yt|jd�}Wq�tk
r�ttd�|j�tj�q�Xn	tj}t	j
dt�}t	j|d|�|_
tj|j
�|_|j�dS(s,Parse document in specified file or on stdintrs!Unable to open specified file: %ss%Unable to open object member file: %st	huge_treetparserN(R4topentIOErrorR%t_Rtexittsvg_filetstdinR*t	XMLParserRtparseRORAtdeepcopyRPtclose(RXtfilenametstreamtp((s'/usr/share/inkscape/extensions/inkex.pyRh�s"

	c	Cs,|jj�|_d	|_|jjddt�}|rx|d}|jjd|dt�}|rx|d|_qxn|jjddt�}|jjddt�}|r(|r(|j|dd�}|j|dd�}|j|j��}|r(|r(t|�|t|�f|_q(ndS(
Ngs,//sodipodi:namedview/@inkscape:current-layert
namespacesis//svg:g[@id="%s"]s!//sodipodi:namedview/@inkscape:cxs!//sodipodi:namedview/@inkscape:cytpx(gg(	ROtgetroott
current_layertview_centertxpathR6tunittouutgetDocumentHeighttfloat(	RXt	layerattrt	layernametlayertxattrtyattrtxtyt
doc_height((s'/usr/share/inkscape/extensions/inkex.pyt
getposinlayer�s 	
cCsUxN|jjD]@}d|}x-|jj|dt�D]}||j|<q6Wq
WdS(sCollect selected nodess
//*[@id="%s"]RnN(RTRKRORsR6RR(RXtitpathtnode((s'/usr/share/inkscape/extensions/inkex.pytgetselected�s
cCs8d|}|jj|dt�}|r0|dSdSdS(Ns
//*[@id="%s"]Rni(RORsR6R4(RXtidR�tel_list((s'/usr/share/inkscape/extensions/inkex.pytgetElementById�s

cCs4x-|jj�D]}||j�kr|SqWdS(N(ROtgetiteratortgetchildren(RXR�tparent((s'/usr/share/inkscape/extensions/inkex.pyt
getParentNode�scCs:|jjddt�}x|D]}d|j|<qWdS(Ns//@idRni(RORsR6RS(RXt
docIdNodestm((s'/usr/share/inkscape/extensions/inkex.pyt	getdocids�s
cCs|jjddt�dS(Ns//sodipodi:namedviewRni(RORsR6(RX((s'/usr/share/inkscape/extensions/inkex.pytgetNamedView�scCs}it|�dt|�d6ttt|���dttt|���d6}tj|j�tdd�|�}|S(Nt,tpositiontorientationtguidetsodipodi(RtsintradianstcosR*t
SubElementR�R:(RXtposXtposYtangletattsR�((s'/usr/share/inkscape/extensions/inkex.pytcreateGuides7	cCsJtj|j�}tj|j�}||krF|jjtj�ndS(s%Serialize document into XML on stdoutN(R*ttostringRPRORRtstdout(RXtoriginaltresult((s'/usr/share/inkscape/extensions/inkex.pytoutputscCsj|d|_t�|j|�|j�|j�|j�|j�|j�|rf|j�ndS(s-Affect an SVG document with a callback effecti����N(	ReRR]RhRR�R�R[R�(RXRUR�((s'/usr/share/inkscape/extensions/inkex.pytaffects






cCsI|}|rEx&||jkr4|tjd�7}qWd|j|<n|S(Nt>0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZi(RStrandomtchoice(RXtold_idtmake_new_idtnew_id((s'/usr/share/inkscape/extensions/inkex.pytuniqueIdscCsHy |jj|dt�d}Wn!ttd�|�d}nX|S(NRnis#No matching node for expression: %s(RORsR6R%RcR4(RXR�tretval((s'/usr/share/inkscape/extensions/inkex.pytxpathSingle's 
gX@ting�UUUU�?tptg�?Rog:Z��x<@tmmgd�/���B@tcmg�:��@R�gd�����LAtkmg0@tpcg�@tydg�@tftcCsV|jj�jd�}|r"|S|jj�jd�}|rN|j�dSdSdS(NtwidthtviewBoxit0(RORptgettsplit(RXR�tviewbox((s'/usr/share/inkscape/extensions/inkex.pytgetDocumentWidth4scCsV|jj�jd�}|r"|S|jj�jd�}|rN|j�dSdSdS(s�Returns a string corresponding to the height of the document, as
        defined in the SVG file. If it is not defined, returns the height
        as defined by the viewBox attribute. If viewBox is not defined,
        returns the string '0'.theightR�iR�N(RORpR�R�(RXR�R�((s'/usr/share/inkscape/extensions/inkex.pyRu@scCs�d}|j�}|jj�jd�}|r�tjddj|jj���}tjd�}|j	|�}|j
|�}d}d}	d}
|r�t|j|j
�|j�!�}nttd��|r�|j|j
�|j�!}
ng}x?|j�D]1}y|jt|��Wqtk
r7qXqWt|�dkr[|d	}	n|j|
||	}
d
}x6|jD](}t|j||
|�r�|}q�q�Wn|S(s!Returns the unit used for in the SVG document.
        In the case the SVG document lacks an attribute that explicitly
        defines what units are used for SVG coordinates, it tries to calculate
        the unit from the SVG width and viewBox attributes.
        Defaults to 'px' units.RoR�s(%s)$t|s:(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)ids1SVG Width not set correctly! Assuming width = 100iig{�G�z�?(R�RORpR�tretcompiletjoint_Effect__uuconvtkeystmatchtsearchRvRItstarttendR%RcR�RGt
ValueErrorR5R)(RXtsvgunittsvgwidtht
viewboxstrt	unitmatchtparamRmtuR�tviewboxwidthtsvgwidthunittviewboxnumbersttt
svgunitfactorR(tkey((s'/usr/share/inkscape/extensions/inkex.pytgetDocumentUnitOs<%%

cCs�tjddj|jj���}tjd�}|j|�}|j|�}|r}t|j|j	�|j
�!�}nd}|r�y:||j|j|j	�|j
�!|j|j�SWq�tk
r�q�Xn||j|j�S|S(sJReturns userunits given a string representation of units in another systems(%s)$R�s:(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)g(
R�R�R�R�R�R�R�RvRIR�R�R�R(RXRItunitR�RmR�R�((s'/usr/share/inkscape/extensions/inkex.pyRt~s%%:
cCs ||j||j|j�S(N(R�R�(RXR9R�((s'/usr/share/inkscape/extensions/inkex.pytuutounit�scCs5yt|�||j�SWntk
r0|SXdS(s:Add document unit when no unit is specified in the string N(RvR�R�(RXR1((s'/usr/share/inkscape/extensions/inkex.pytaddDocumentUnit�s


N(R=R>t__doc__RZR[RtargvR]R4RhRR�R�R�R�R�R�R�RR�R�R�R�R�RuR�RtR�R�(((s'/usr/share/inkscape/extensions/inkex.pyRC�s0									
	
		&&			/		((R�RARR-R
R�R�RtmathR6RRR%R)tlxmlR*tImportErrorteRcRdR2R4R:R?R;RC(((s'/usr/share/inkscape/extensions/inkex.pyt<module>sB