403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/inkscape/extensions/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/share/inkscape/extensions/__pycache__/synfig_prepare.cpython-310.pyc
o

0�aR7�@s�dZddlZddlZddlmZmZddlZddlmZmZm	Z	m
Z
mZmZm
Z
mZGdd�de�ZGdd�de�ZGd	d
�d
e�Zdd�Zd
d�Zigd�gd�gfdd�Zddd�ZGdd�dej�Zedkrpe���dSdS)z5
Simplifies SVG files in preparation for sif export.
�N)�PIPE�Popen)�load_svg�Group�PathElement�ShapeElement�Anchor�Switch�SvgDocumentElement�	Transformc@s eZdZdZdd�Zdd�ZdS)�MalformedSVGErrorzHRaised when the SVG document is invalid or contains unsupported featurescCs
||_dS�N)�value)�selfr�r�0/usr/share/inkscape/extensions/synfig_prepare.py�__init__%s
zMalformedSVGError.__init__cCsdt|j�S)NaSVG document is invalid or contains unsupported features

Error message: %s

The SVG to Synfig converter is designed to handle SVG files that were created using Inkscape. Unsupported features are most likely to occur in SVG files written by other programs.
)�reprr�rrrr�__str__(s�zMalformedSVGError.__str__N)�__name__�
__module__�__qualname__�__doc__rrrrrrr"src@sreZdZdZddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)�InkscapeActionGroupz@A class for calling Inkscape to perform operations on a documentNcCs&d|_d|_d|_d|_|�|�dS)N�F)�command�	init_args�
has_selection�
has_action�set_svg_document�r�svg_documentrrrr4s
zInkscapeActionGroup.__init__cCs||_|��|_dS)z2Set the SVG document that Inkscape will operate onN)r"�getroot�svgr!rrrr ;sz$InkscapeActionGroup.set_svg_documentcCs
||_dS)z�Set the initial arguments to Inkscape subprocess

        Can be used to pass additional arguments to Inkscape, or an initializer
        command (e.g. unlock all objects before proceeding).
        N)r)r�cmdrrr�
set_init_args@s
z!InkscapeActionGroup.set_init_argscCsd|_d|_d|_dS)zClear all actionsrFN)rrrrrrr�clearHs
zInkscapeActionGroup.clearcCs0|jr|jd|7_|jsd|_dSdSdS)zVRun an Inkscape verb

        For a list of verbs, run `inkscape --verb-list`
        z
--verb=%s TN)rrr)r�verbrrrr(Ns
�zInkscapeActionGroup.verbcCs&|jd|7_|jsd|_dSdS)zSelect object with given idz--select=%s TN)rr)r�	object_idrrr�	select_idYs
�zInkscapeActionGroup.select_idcCs*|�dd�}|durtd��|�|�dS)zoSelect the object represented by the SVG node

        Selection will fail if node has no id attribute
        �idNzNode has no id)�getrr*)r�node�node_idrrr�select_node_szInkscapeActionGroup.select_nodecCs|D]}|�|�qdS)zmSelect objects represented by SVG nodes

        Selection will fail if any node has no id attribute
        N)r/)r�nodesr-rrr�select_nodesis�z InkscapeActionGroup.select_nodescCs|�|j�|��dS)zSelect objects matching a given XPath expression

        Selection will fail if any matching node has no id attribute
        N)r1r$�xpath)rr2rrr�select_xpathqsz InkscapeActionGroup.select_xpathcCs|jr
|�d�d|_dSdS)zDeselect all objects�EditDeselectFN)rr(rrrr�deselectxs

�zInkscapeActionGroup.deselectcCs^|jsdS|jd|jd}td�||�dttd�}|��}|j}|j}|�	�|�	�dS)z"Run the actions on a specific fileN� z--verb=FileSave --verb=FileQuitzinkscape "{}" {}T)�shell�stdout�stderr)
rrrr�formatr�waitr8r9�close)r�filenamer%�p�rc�f�errrrr�run_file~szInkscapeActionGroup.run_filecCs�|js|jSt�d�}|j�|�|�|�t|d��
}t|�|_Wd�n1s+wYz	t�	|�W|jSt
yDY|jSw)z#Run the actions on the svg xml treez.svg�rN)rr"�tempfile�mktemp�writerB�openr�os�remove�	Exception)r�svgfile�streamrrr�run_document�s

���z InkscapeActionGroup.run_documentr
)rrrrrr r&r'r(r*r/r1r3r5rBrMrrrrr1s

rc@s*eZdZdZd	dd�Zdd�Zdd�ZdS)
�SynfigExportActionGroupzAAn action group with stock commands designed for Synfig exportingNcCs*t�||�|�d�|��|��dS)Nz--verb=UnlockAllInAllLayers)rrr&�objects_to_paths�
unlink_clonesr!rrrr�s
z SynfigExportActionGroup.__init__cCsX|�d�|�d�|��gd�}d�dd�|D��}|�|�|�d�|��dS)z$Convert unsupported objects to pathsz//svg:flowRoot�ObjectToPath)zsvg:rectz
svg:circlezsvg:ellipsezsvg:linezsvg:polylinezsvg:polygonzsvg:textz | cSsg|]}d|�qS)z//r)�.0�nprrr�
<listcomp>��z<SynfigExportActionGroup.objects_to_paths.<locals>.<listcomp>N)r3r(r5�join)r�	non_paths�	xpath_cmdrrrrO�s



z(SynfigExportActionGroup.objects_to_pathscCs |�d�|�d�|��dS)z)Unlink clones (remove <svg:use> elements)z	//svg:use�EditUnlinkCloneN)r3r(r5rrrrrP�s

z%SynfigExportActionGroup.unlink_clonesr
)rrrrrrOrPrrrrrN�s

rNcCs�|j��}t|�dkr
dSd}||dd||ddg}|dd�}g}|t|�kr�||ddkr=|�dgg�q'||ddkrT||dd|d<|d7}q'||ddkrk||dd|d<|d7}q'|ddd	ksw|dkr�||ddd�}|d7}q'||dd	ks�J�d
||d<||kr�|�|d
|g�|d7}||ddd�}|�|�|t|�ks-|r�d
|��g}|�||�|d7}|s�tt�	|��}|�
d|�dS)z?Fuse subpaths of a path. Should only be used on unstroked pathsrN��������Z�V�H�M�L�d)�path�	to_arrays�lenrI�insert�append�pop�str�inkex�Path�set)�	path_noderc�i�
initial_point�prev_end�return_stack�el�path_drrr�
fuse_subpaths�sL
 
�%�rtcCs�ttj�|�dd���}d|vr(|ddkr(d|vs |ddkr$ddgSd|gSd|��vs4|ddkr8|dgSt�}|�t��}|�t��}|�	d�}|durTt
d��|�	d	d�}|�	d
tt|���}|�	dd�}|�	d�|j
��D]
\}	}
|�|	|
�qt|�d
|�i}ddd
�}ddd�}
|��D]>}|�d�r�||||<q�|�d�r�|||
|<q�|�d�r�|||
|<q�|�d�r�||||<q�||||<|||
|<q�t|�dkr�|�dtt�|���|�dtt�|���|�dtt�|
���|�d|�|�d|�|du�r|�d	|�|�d	|�|�d
|d�|�d
|d�|du�r9|�d|�|�d|�|���||�||gS)z�Split a path into two paths, one filled and one stroked

    Returns a the list [fill, stroke], where each is the XML element of the
    fill or stroke, or None.
    �styler�fill�none�strokeNrbz0Cannot split stroke and fill of non-path elementzsodipodi:nodetypesr+�	transformz#000000)rxrv)rvrx�marker�filterrz-fillz-stroke)�dictrj�Style�	parse_strr,�keysr�addrrh�AssertionErrorrir+�attrib�itemsrl�
startswithre�	getparent�replace)rmru�grouprvrxrb�	nodetypes�path_idry�attrib_name�attrib_value�style_group�
style_fill�style_stroke�keyrrr�split_fill_and_strokesd









r�)��?�r�)r�r�r�cCs�t|ttf�s	dSt|t�rE|�d�rEdd�|��D�\}}}}t|�d|��}t|�d|��}t||f||||fd�}	|jd=nt|�}	|	|j9}	t	t
j�|�dd	���}
i}d
g}|D]}
|
|
�
�vrr|
|
||
<|
|
=qa|��}|�|
�|}
ddg}|D]}|�|�r�|�|�|
|<|j|=q�t|ttttf�r�|r�||_n
d|�
�vr�|jd=d
|�
�vr�|jd
=|��D]}t||
|	�q�dS|
�|�|
|_|	|_dS)z3Propagate style and transform to remove inheritanceN�viewBoxcSsg|]}t|��qSr)�
get_dimension)rR�xrrrrTjrUz%propagate_attribs.<locals>.<listcomp>�width�height)�	translate�scalerurr{rvrxry)�
isinstancerr
r,�get_viewboxr�rr�ryr|rjr}r~r�copy�updaterrr	ru�iterchildren�propagate_attribs)r-�parent_style�parent_transform�vx�vy�vw�vh�dw�dh�this_transform�
this_style�remaining_style�non_propagatedr��parent_style_copy�
style_attribsr��childrrrr�asP 

�

��

r��1024cCstj�|d�S)z;Convert an SVG length string from arbitrary units to pixels�px)rj�units�convert_unit)�srrrr��sr�c@seZdZdd�ZdS)�
SynfigPrepcCsrt|j�}|��|_t|j���|j���d�D]}|�dd����d�dkr6t	|�d}|dur6t
|�qdS)zITransform document in preparation for exporting it into the Synfig formatz
//svg:pathrbr�mrZrN)rN�documentrMr�r#r2r,�lower�countr�rt)r�ar-rvrrr�effect�s

��zSynfigPrep.effectN)rrrr�rrrrr��sr��__main__)r�)rrHrD�
subprocessrrrjrrrrrr	r
rrJr�objectrrNrtr�r�r��EffectExtensionr�r�runrrrr�<module>s"(u19Q
E�

Youez - 2016 - github.com/yon3zu
LinuXploit