
    BPc+'                         d Z ddlZddlZddlmZ ddlmZ ddlmZ ddlmZmZ ddl	m
Z d	d
lmZ  G d d          Z G d deee          ZdS )zD
Deprecation functionality for the pre-1.0 Inkex main effect class.
    N)ArgumentParser   )utils)base)SvgThroughMixinInkscapeExtension)inkex_gettext   )_deprecatedc                       e Zd ZdZ ej                    Z fdZe e	d          dfd            Z
ed             Zd Zd Zed	             Zed
             Zed             Zed             Zd Zd Zd Zd Zd Zd Zd Zej        dd         dfdZed             Zed             Zd Zd"dZ d Z!d Z"d Z#d Z$d  Z%d! Z& xZ'S )#DeprecatedEffectzNAn Inkscape effect, takes SVG in and outputs SVG, providing a deprecated layerc                 0   t                                                       d | _        d | _        t	          | d          sddlm}  |            | _        t	          | d          st                      | _	        t	          | d          s| j
        | _        d S d S )Nsvgr   )SvgDocumentElement
arg_parserrun)super__init___doc_ids_argshasattrelementsr   r   r   r   affectr   )selfr   	__class__s     C/usr/share/inkscape/extensions/inkex/deprecated/deprecatedeffect.pyr   zDeprecatedEffect.__init__,   s    

 tU## 	,555555))++DHt\** 	/,..DOtU## 	#{DHHH	# 	#    z&{} is deprecated and should be removed   c                 x    t          |                    d|z   | j        dz   | j        z             |           dS )zDGive the user a warning about their extension using a deprecated APIzEffect..)clsstackN)r   format
__module____name__)r!   namemsgr#   s       r   r   zDeprecatedEffect._deprecated=   sN    
 	JJy4'S^c-ACL-PJQQ	
 	
 	
 	
 	
 	
r   c                 L    |                      dt          d                     | S )NOptionParserz{} or `optparse` has been deprecated and replaced with `argparser`. You must change `self.OptionParser.add_option` to `self.arg_parser.add_argument`; the arguments are similar.r   _r   s    r   r*   zDeprecatedEffect.OptionParserG   s7    M 	
 	
 	
 r   c                     d|v r<t           t          t          t          j        d                    |d                   |d<   |                    dd           dk    r|                    d           d |D             } | j        j        |i | d S )Ntype)stringintfloatinkboolactionstorec                     g | ]
}|d k    |S )  ).0args     r   
<listcomp>z/DeprecatedEffect.add_option.<locals>.<listcomp>_   s    111sbyyyyyr   )	strr1   r2   r   Booleangetpopr   add_argument)r   argskws      r   
add_optionzDeprecatedEffect.add_optionS   s    R<< =	 
 c"V*oo vJ 66(D!!W,,FF811t111$$d1b11111r   c                 L    |                      dt          d                     d S )Neffectz[{} method is now a required method. It should be created on {cls}, even if it does nothing.r+   r-   s    r   rE   zDeprecatedEffect.effectb   s:    @ 	
 	
 	
 	
 	
r   c                 z    |                      dt          d                     | j                                        S )Ncurrent_layerz_{} is now a method in the SvgDocumentElement class. Use `self.svg.get_current_layer()` instead.)r   r,   r   get_current_layerr-   s    r   rG   zDeprecatedEffect.current_layerk   sE    > 	
 	
 	
 x))+++r   c                 j    |                      dt          d                     | j        j        j        S )Nview_centerza{} is now a method in the SvgDocumentElement class. Use `self.svg.get_center_position()` instead.)r   r,   r   	namedviewcenterr-   s    r   rJ   zDeprecatedEffect.view_centerv   s@    @ 	
 	
 	
 x!((r   c                 t    |                      dt          d                     d | j        j        D             S )NselectedzJ{} is now a dict in the SvgDocumentElement class. Use `self.svg.selected`.c                 :    i | ]}|                     d           |S )id)r>   )r9   elems     r   
<dictcomp>z-DeprecatedEffect.selected.<locals>.<dictcomp>   s$    CCCCCCr   )r   r,   r   rN   r-   s    r   rN   zDeprecatedEffect.selected   sK    + 	
 	
 	
 DC1BCCCCr   c                     |                      dt          d                     | j        6t                              | j                                                  | _        | j        S )Ndoc_idszU{} is now a method in the SvgDocumentElement class. Use `self.svg.get_ids()` instead.)r   r,   r   dictfromkeysr   get_idsr-   s    r   rT   zDeprecatedEffect.doc_ids   sb    4 	
 	
 	
 =  MM$(*:*:*<*<==DM}r   c                     |                      dt          d                     d | _        | j        j                                         d S )N	getdocidsz5Use `self.svg.get_ids()` instead of {} and `doc_ids`.)r   r,   r   r   idsclearr-   s    r   rY   zDeprecatedEffect.getdocids   sM    RSS	
 	
 	
 r   c                 L    |                      dt          d                     d S )Ngetselectedz{} has been removedr+   r-   s    r   r]   zDeprecatedEffect.getselected   s'    *?(@(@AAAAAr   c                 |    |                      dt          d                     | j                            |          S )NgetElementByIdz_{} is now a method in the SvgDocumentElement class. Use `self.svg.getElementById(eid)` instead.)r   r,   r   r_   )r   eids     r   r_   zDeprecatedEffect.getElementById   sG    > 	
 	
 	
 x&&s+++r   c                 |    |                      dt          d                     | j                            |          S )NxpathSinglez`{} is now a new method in the SvgDocumentElement class. Use `self.svg.getElement(path)` instead.)r   r,   r   
getElement)r   xpaths     r   rb   zDeprecatedEffect.xpathSingle   sG    ; 	
 	
 	
 x""5)))r   c                 p    |                      dt          d                     |                                S )NgetParentNodezC{} is no longer in use. Use the lxml `.getparent()` method instead.)r   r,   	getparent)r   nodes     r   rf   zDeprecatedEffect.getParentNode   s;    STT	
 	
 	
 ~~r   c                 `    |                      dt          d                     | j        j        S )NgetNamedViewzf{} is now a property of the SvgDocumentElement class. Use `self.svg.namedview` to access this element.)r   r,   r   rK   r-   s    r   rj   zDeprecatedEffect.getNamedView   s=    C 	
 	
 	
 x!!r   c                     ddl m} |                     dt          d                     | j        j                             |                                |||                    S )Nr   )GuidecreateGuidezs{} is now a method of the namedview element object. Use `self.svg.namedview.add(Guide().move_to(x, y, a))` instead.)r   rl   r   r,   r   rK   addmove_to)r   posXposYanglerl   s        r   rm   zDeprecatedEffect.createGuide   ss    $$$$$$R 	
 	
 	
 x!%%eeggoodD%&H&HIIIr   r
   NTc                     |                      dt          d                     |dd          | _        |                     |          S )Nr   z<{} is now `Effect.run()`. The `output` argument has changed.)rA   )r   r,   r   r   )r   rA   outputs      r   r   zDeprecatedEffect.affect   sO     	aVWW	
 	
 	
 "##Y
xxTx"""r   c                 V    |                      dt          d                     | j        S )NrA   z-self.args[-1] is now self.options.input_file.)r   r,   r   r-   s    r   rA   zDeprecatedEffect.args   s)    #R!S!STTTzr   c                 `    |                      dt          d                     | j        j        S )Nsvg_filez-self.svg_file is now self.options.input_file.)r   r,   options
input_filer-   s    r   rx   zDeprecatedEffect.svg_file   s,    Q'V%W%WXXX|&&r   c                     t          | j        d          r0|                     ddd            t          | d                      S t          j                            | |          S )Nru   z%Use `save()` or `save_raw()` instead.   r"   )r   r   r   getattrr   r   save_raw)r   rets     r   r~   zDeprecatedEffect.save_raw   sf     4>8,, 	-X'NVWXXX*74**,,,%..tS999r   c                 |    |                      dt          d                     | j                            |          S )NuniqueIdzb{} is now a method in the SvgDocumentElement class.  Use `self.svg.get_unique_id(old_id)` instead.)r   r,   r   get_unique_id)r   old_idmake_new_ids      r   r   zDeprecatedEffect.uniqueId   sH    A 	
 	
 	
 x%%f---r   c                 |    |                      dt          d                     | j                            d          S )NgetDocumentWidthzS{} is now a property of the SvgDocumentElement class. Use `self.svg.width` instead.widthr   r,   r   r>   r-   s    r   r   z!DeprecatedEffect.getDocumentWidth   sE    0 	
 	
 	
 x||G$$$r   c                 |    |                      dt          d                     | j                            d          S )NgetDocumentHeightzT{} is now a property of the SvgDocumentElement class. Use `self.svg.height` instead.heightr   r-   s    r   r   z"DeprecatedEffect.getDocumentHeight  sE    1 	
 	
 	
 x||H%%%r   c                 `    |                      dt          d                     | j        j        S )NgetDocumentUnitzR{} is now a property of the SvgDocumentElement class. Use `self.svg.unit` instead.)r   r,   r   unitr-   s    r   r   z DeprecatedEffect.getDocumentUnit  s;    / 	
 	
 	
 x}r   c                 |    |                      dt          d                     | j                            |          S )NunittouuzY{} is now a method in the SvgDocumentElement class. Use `self.svg.unittouu(str)` instead.)r   r,   r   r   )r   r0   s     r   r   zDeprecatedEffect.unittouu  sG    8 	
 	
 	
 x  (((r   c                 ~    |                      dt          d                     | j                            ||          S )Nuutounitza{} is now a method in the SvgDocumentElement class. Use `self.svg.uutounit(value, unit)` instead.)r   r,   r   r   )r   valr   s      r   r   zDeprecatedEffect.uutounit#  sJ    @ 	
 	
 	
 x  d+++r   c                 |    |                      dt          d                     | j                            |          S )NaddDocumentUnitz[{} is now a method in the SvgDocumentElement class. Use `self.svg.add_unit(value)` instead.)r   r,   r   add_unit)r   values     r   r   z DeprecatedEffect.addDocumentUnit-  sG    : 	
 	
 	
 x  '''r   )T)(r&   r%   __qualname____doc__argparse	Namespacery   r   classmethodr,   r   propertyr*   rC   rE   rG   rJ   rN   rT   rY   r]   r_   rb   rf   rj   rm   sysargvr   rA   rx   r~   r   r   r   r   r   r   r   __classcell__)r   s   @r   r   r   '   sm       XX h ""G# # # # #" qABB!
 
 
 [
 	 	 X	2 2 2
 
 
 , , X, ) ) X) D D XD 
 
 X
  B B B, , ,* * *     " " "
J 
J 
J 8ABB<# # # #   X ' ' X': : :. . . .% % %& & &  ) ) ), , ,( ( ( ( ( ( (r   r   c                       e Zd ZdZdS )Effectz0An Inkscape effect, takes SVG in and outputs SVGN)r&   r%   r   r   r8   r   r   r   r   8  s        ::::r   r   )r   r   r   r   r7   r   r   r   r   localizationr	   r,   metar   r   r   r8   r   r   <module>r      s   &  


  # # # # # #             5 5 5 5 5 5 5 5 - - - - - -      N( N( N( N( N( N( N( N(b; ; ; ; ;_.0A ; ; ; ; ;r   