
ddc           @` sn   d  Z  d d l m Z m Z m Z m Z d d l Td d l Z d e f d     YZ	 d e
 f d     YZ d S(	   u:   Management of version numbers (particularly incrementing).i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   *Nt   Versionc           B` s   e  Z d d d d d d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d d	  Z e d
    Z e d    Z e d    Z e d    Z e d    Z e d    Z RS(   c         C` s1   | |  _  | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   majort   minort   patcht
   prereleaset   prerelease_patch(   t   selfR   R   R   R	   R
   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __init__   s
    				c         C` s   d j  |  j |  j  } |  j d  k	 r@ | d j  |  j  7} n  |  j d  k	 r | d j  |  j  7} |  j d  k	 r | d j  |  j  7} q n  | S(   Nu   {}.{}u   .{}u   -{}(   t   formatR   R   R   t   NoneR	   R
   (   R   t   version_str(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __str__   s    c         C` sQ   d j  |  j j |  j |  j |  j |  j d  k	 rA d |  j d n |  j |  j  S(   Nu   {}({}, {}, {}, {}, {})u   "(	   R   t	   __class__t   __name__R   R   R   R	   R   R
   (   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __repr__"   s    &c         C` s   |  j  |   } |  j  |  } | | k  r. t S| | k r> t S|  j d  k	 r` | j d  k r` t S|  j d  k	 r | j d  k	 r |  j | j k  r t S|  j | j k r t S|  j |  j  |  j | j  k  Sn t Sd  S(   N(   t   _get_main_components_tuplet   Truet   FalseR	   R   t   _get_default_numberR
   (   R   t   other_versiont   this_version_main_componentst   other_version_main_components(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __lt__(   s     c         C` s   |  j  |  p |  j |  S(   N(   R   t   __eq__(   R   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __le__?   s    c         C` sR   |  j  |   |  j  |  k oQ |  j | j k oQ |  j |  j  |  j | j  k S(   N(   R   R	   R   R
   (   R   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR   B   s
    c         C` s   |  j  |  S(   N(   R   (   R   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __ne__J   s    c         C` s   |  j  |  S(   N(   R   (   R   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __gt__M   s    c         C` s   |  j  |  S(   N(   R   (   R   R   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   __ge__P   s    c   
      ` s  | d k r$ t  d j |    n    r t j d    sT t  d j      n     j k  r t  d j    j    q n    s d   n   f d   }  f d	   }  f d
   }  f d   }    f d   }  f d   } | d k r| }	 n* | d k r| }	 n | d k r/| }	 n    d k rL|	   |   n@  j d k rl|	   |   n     j k r|   n |   d S(   u  
    Increment the version as per `component_to_increment` and `prerelease`.
    
    `component_to_increment` can be `'major'`, `'minor'` or `'patch'`. Given the
    format `X.Y.Z`, `'major'` increments `X`, `'minor'` increments `Y` and
    `'patch'` increments `Z`. If `patch` attribute is `None` and `'patch'` is
    specified, `1` will be assigned (e.g. `3.3` becomes `3.3.1`).
    
    If the `prerelease` string is not `None` and non-empty, append the
    pre-release to the version. For example, `3.3` with `'major'` compoment and
    `'alpha'` as the pre-release string becomes `4.0-alpha`.
    
    If the version already has the same pre-release, append a number to the
    pre-release (e.g. `4.0-alpha` becomes `4.0-alpha.2`).
    
    If the version already has a different pre-release (lexically earlier than
    `prerelease`), replace the existing pre-release with `prerelease` (e.g.
    `4.0-alpha` with the `'beta'` pre-release becomes `4.0-beta`).
    
    Raises:
    
    * `ValueError`:
      
      * Invalid value for `component_to_increment`.
      * The specified `prerelease` contains non-alphanumeric characters or is
        lexically earlier than the existing `prerelease` attribute.
    u   majoru   minoru   patchu   invalid version component "{}"u   ^[a-zA-Z0-9]+$u   invalid pre-release format "{}"uV   the specified pre-release "{}" is lexically earlier than the existing pre-release "{}"c           ` s%     j  d 7_  d   _ d    _ d  S(   Ni   i    (   R   R   R   R   (    (   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   increment_major~   s    	c           ` s     j  d 7_  d    _ d  S(   Ni   (   R   R   R   (    (   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   increment_minor   s    c           ` s.     j  d  k r d   _  n    j  d 7_  d  S(   Ni    i   (   R   R   (    (   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   increment_patch   s    c           ` s   d    _ d    _ d  S(   N(   R   R	   R
   (    (   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   clear_prerelease   s    	c           ` s      _  d   _ d  S(   N(   R	   R   R
   (    (   R	   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   set_new_prerelease   s    	c           ` s.     j  d  k r d   _  n    j  d 7_  d  S(   Ni   (   R
   R   (    (   R   (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   increment_prerelease   s    N(   u   majoru   minoru   patch(   t
   ValueErrorR   t   ret   searchR	   R   (
   R   t   component_to_incrementR	   R!   R"   R#   R$   R%   R&   t   increment_component_func(    (   R	   R   sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt	   incrementS   s@    				


c         C` s   t    } |  j | |  | S(   u   
    Parse the `version_str` string and return a `Version` instance.
    
    Raises:
    
    * `InvalidVersionFormatError` - `version_str` has invalid format.
    (   R   t   _fill_version_components(   t   clsR   t   ver(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   parse   s    		c         C` sk   | j  d  } t |  d k r* t  n  |  j | | d  t |  d k rg |  j | | d  n  d  S(   Nu   -i   i    i   (   t   splitt   lent   InvalidVersionFormatErrort   _set_main_version_componentst"   _set_prerelease_version_components(   R.   t   version_objR   t   version_str_components(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR-      s    	c         C` s   t  j d |  } | d  k rH t  j d |  } | d  k rH t  qH n  | j   } t | d  | _ t | d  | _ t |  d k r t | d  | _	 n  d  S(   Nu   ^([0-9]+?)\.([0-9]+?)$u%   ^([0-9]+?)\.([0-9]+?)\.([1-9][0-9]*)$i    i   i   i   (
   R(   R)   R   R3   t   groupst   intR   R   R2   R   (   R.   R6   t   main_str_componentst   matcht   match_groups(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR4      s    c         C` s   t  j d |  } | d  k rH t  j d |  } | d  k rH t  qH n  | j   } | d | _ t |  d k r t | d  | _ n  d  S(   Nu   ^([a-zA-Z0-9]+?)$u&   ^([a-zA-Z0-9]+?)\.([2-9]|[1-9][0-9]+)$i    i   i   (	   R(   R)   R   R3   R8   R	   R2   R9   R
   (   R.   R6   t   prerelease_str_componentsR;   R<   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR5      s    c         C` s&   t  d   |  j |  j |  j g D  S(   Nc         s` s'   |  ] } | d k	 r | n d  Vq d S(   iN(   R   (   t   .0t   number(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pys	   <genexpr>   s   (   t   tupleR   R   R   (   R/   (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR      s    c         C` s   |  d  k	 r |  Sd S(   Ni(   R   (   t	   component(    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR      s    N(   R   t
   __module__R   R   R   R   R   R   R   R   R   R    R,   t   classmethodR0   R-   R4   R5   t   staticmethodR   R   (    (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR      s    								ZR3   c           B` s   e  Z RS(    (   R   RB   (    (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyR3      s   (   t   __doc__t
   __future__R    R   R   R   t   future.builtinsR(   t   objectR   t	   ExceptionR3   (    (    (    sI   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/version.pyt   <module>   s
   "
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    ddF2                     N   d dl mZmZmZmZ d dlZd dlZd dlZd dlZej	        
                    ej	                             ej         ej                                                  Z	 d dlZdZn# e$ r dZY nw xY wddlmZ er/ ej        dej	                            e          egddd	
           erddlmZ  ej        dd           d Z eej	                            ed                     d dlmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- d dl.Z.d dl/Z/d dl0Z0ddl1T ddlm2Z2 ddlm3Z3 er\d dl4Z4d dl5Z5ddlm6Z6 ddlm7Z7 ddlm8Z8 ddlm9Z9 ddlm:Z: ddlm;Z; ddlm<Z< ddlm	Z	 ddlm=Z= ddlm>Z> ddlm?Z? d dlm@Z@ ddl?mAZA dd l?mBZB g d!ZCereCD                    g d"           daE G d# d$e%          ZFd% ZGd& ZHd' ZId( ZJd) ZK eG             er@ e/jL                    ZM e/jL                    ZNd* ZOd+ ZP	 	 	 	 	 	 	 	 	 	 d3d.ZQd/ ZRd0 ZSd1 ZTd2 ZUdS dS )4    )absolute_importdivisionprint_functionunicode_literalsNTF   )logging
exceptions	error.log	pygimplib)log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title)_gui_messages)titleapp_namec                    t          j        |           D ]n}t           j                            | |          }t           j                            |          r-|t
          j        vrt
          j                            |           odS )ad  
  Add directory paths containing external libraries for pygimplib to `sys.path`
  so that modules from these external libraries can be imported as system
  modules (i.e. without using absolute or explicit relative imports).
  
  Modules with the same name that are already installed system-wide override the
  external library modules from `pygimplib`.
  N)oslistdirpathjoinisdirsysappend)dirpathfilenameexternal_libs_dirpaths      J/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/__init__.py%_setup_import_of_external_lib_modulesr    &   sw     *W%% - -hGLL(;;	w}}*++ -0ESX0U0U	hoo+,,,- -    _lib)asciibyteschrdictfilterhexinputintlistmapnextobjectoctopenpowrangeroundstrsuperzip)*)utils)version)invoker)fileformats)
invocation)gui)itemtree)objectfilter)	overwrite)r   )pdbutils)progress)setting)pdb)SettingGuiTypes)SettingTypes)r   r8   r9   configinit)r:   r;   r<   r=   r>   r?   r@   r   rA   rB   rC   rD   	proceduremainrE   rF   c                   0     e Zd Z fdZd Zd Zd Z xZS )_Configc                 L    t                                          di            d S )N_config)r5   __setattr__)self	__class__s    r   __init__z_Config.__init__   s#    	GG	2&&&&&r!   c                     || j         |<   d S NrN   )rP   namevalues      r   rO   z_Config.__setattr__   s    DLr!   c                     || j         vr"t          d                    |                    | j         |         }t          |          r
 |            S |S )Nz"configuration entry "{}" not found)rN   AttributeErrorformatcallable)rP   rV   attrs      r   __getattr__z_Config.__getattr__   sV    4<?FFtLLMMM<D~~ TVVmkr!   c                     || j         v S rT   rU   )rP   rV   s     r   __hasattr__z_Config.__hasattr__   s    4<r!   )__name__
__module____qualname__rR   rO   r]   r_   __classcell__)rQ   s   @r   rL   rL   }   se        ' ' ' ' '  	 	 	             r!   rL   c                      t           d S d  t                      a t          t           _        t                      lt          j                                      t           _        t           _        t          j        	                              t           _
        d t           _        ndt           _        t          j        	                    t                    t           _        t          j        	                    t           j                  t           _
        t          j        	                    t                    t           _        t           j        t           _        d t           _        dt           _        d t           _         fdt           _        g t           _        t$          rdt           _        nd	t           _        t)          t                      t+                       t-          t                      d S )
Nc                 P    | dS dt           j                            dd          z   S )Nzgimp20-pythonzgimp-plugin-_-)rG   PLUGIN_NAMEreplace)root_plugin_dirpaths    r   _get_domain_namez&_init_config.<locals>._get_domain_name   s+    "_f088cBBBBr!   c                      t           j        S rT   )rG   PLUGIN_DIRPATH r!   r   <lambda>z_init_config.<locals>.<lambda>   s	    &*? r!   gimp_pluginc                      t           j        S rT   )rG   rh   rn   r!   r   ro   z_init_config.<locals>.<lambda>   s	     2 r!   z1.0c                  l    t           j                            t          j        t          j        d          S )Nlocale)r   r   r   rG   PLUGINS_DIRPATHrh   rn   r!   r   ro   z_init_config.<locals>.<lambda>   s    BGLL/1CXNN r!   c                                  S rT   rn   rk   rj   s   r   ro   z_init_config.<locals>.<lambda>   s    //0CDD r!   r	   none)rG   rL   PYGIMPLIB_DIRPATH_get_root_plugin_dirpathr   r   basename_DEFAULT_PLUGIN_NAMErm   dirnamert   DEFAULT_LOGS_DIRPATHrh   PLUGIN_TITLEPLUGIN_VERSIONLOCALE_DIRPATHDOMAIN_NAMEBUG_REPORT_URL_LIST _gimp_dependent_modules_importedLOG_MODE_init_config_builtin_init_config_from_file_init_config_builtin_delayedrv   s   @@r   _init_configr      sp    
FC C C 99&.&022$"$'"2"23F"G"GF/FW__-@AAF"?"?F #0FGOO,=>>FW__V-BCCF"$'//2C"D"DF2&22&& ON 	DDDDD&!&% "FOOFOvv&&&&&r!   c                      t          j                    } | r+t          j                            | d         d                   S d S )Nr   )inspectstackr   r   r|   )frame_stacks    r   ry   ry      s7    + 7??;r?1-...4r!   c                 X   g | _         | j                             | j                   t          rOt          j                            t          j        d          }|| j        k    r| j                             |           | j        | _	        | j        | _
        d| _        d| _        d| _        d S )Nzplug-insz
output.logr
   2   )PLUGINS_LOG_DIRPATHSr   r}   r   r   r   r   gimp	directoryPLUGINS_LOG_STDOUT_DIRPATHPLUGINS_LOG_STDERR_DIRPATHPLUGINS_LOG_STDOUT_FILENAMEPLUGINS_LOG_STDERR_FILENAME'GIMP_CONSOLE_MESSAGE_DELAY_MILLISECONDS)rG   plugins_dirpath_alternates     r   r   r      s     "&$$V%@AAA% D "T^Z H H F$??? !(()BCCC&,&A&#&,&A&#'3&$'2&$35&000r!   c                      d } t          t          d          rt          j        } t          t          _        	 ddlm} n(# t          $ r 	 ddlm} n# t          $ r Y nw xY wY nw xY w| 	t          `d S | t          _        d S )Nc   )
config_devrG   )hasattr__builtin__r   rG    r   ImportError)orig_builtin_cplugin_configs     r   r   r      s    .[# # ]N+-	 /......	   ,,,,,,,   
d "KMMMs3   = 
A"AA"
AA"AA"!A"c                      fd}t           r |             _        t          j         j                   _        t          j         j                   _        t          j        j        	                    t          j        d j        fd j        fg                     t          j         j         j        d           t           s j        dk    r9t#          j         j         j         j         j         j         j                   d S d S )Nc                  Z     j                             d          r j         S d j         z   S )Nplug_inplug_in_)rh   
startswithr   s   r   _get_setting_source_namez>_init_config_builtin_delayed.<locals>._get_setting_source_name   s3    $$Y// -&,,,r!   session
persistentT)unicodegimp_console)r   SOURCE_NAMErC   GimpShelfSourceSESSION_SOURCEGimpParasiteSourcePERSISTENT_SOURCE	persistor	Persistorset_default_setting_sourcescollectionsOrderedDictgettextinstallr   r   r   r   
log_outputr   r   r   r~   r   )rG   r   s   ` r   r   r      s-   - - - - - & 21133F#3F4FGGF&9&:LMMF;;K<S&'(V-.U0 =1 =1 2 2 2 
/&$f&;TJJJJ% KN)J)Jov2(&*L6IK K K K K *K)Jr!   c                        fd}|S )a  Installs a function as a GIMP procedure.
    
    Use this function as a decorator over a function to be exposed to the GIMP
    procedural database (PDB).
    
    The installed procedure can then be accessed via the GIMP (PDB) and,
    optionally, from the GIMP user interface.
    
    The function name is used as the procedure name as found in the GIMP PDB.
    
    The following keyword arguments are accepted:
    
    * `blurb` - Short description of the procedure.
    
    * `description` - More detailed information about the procedure.
    
    * `author` - Author of the plug-in.
    
    * `copyright_holder` - Copyright holder of the plug-in.
    
    * `date` - Dates (usually years) at which the plug-in development was
      active.
    
    * `menu_name` - Name of the menu entry in the GIMP user interface.
    
    * `menu_path` - Path of the menu entry in the GIMP user interface.
    
    * `image_types` - Image types to which the procedure applies (e.g. RGB or
      indexed). Defaults to `'*'` (any image type).
    
    * `parameters` - Procedure parameters. This is a list of tuples of three
      elements: `(PDB type, name, description)`. Alternatively, you may pass a
      `setting.Group` instance or a list of `setting.Group` instances containing
      plug-in settings.
    
    * `return_values` - Return values of the procedure, usable when calling the
      procedure programmatically. The format of `return_values` is the same as
      `parameters`.
    
    Example:
      
      import pygimplib as pg
      
      \@pg.procedure(
        blurb='Export layers as separate images',
        author='John Doe',
        menu_name=_('E_xport Layers...'),
        menu_path='<Image>/File/Export',
        parameters=[
          (gimpenums.PDB_INT32, 'run-mode', 'The run mode'),
          (gimpenums.PDB_IMAGE, 'image', 'The current image'),
          (gimpenums.PDB_STRING, 'dirpath', 'Output directory path')]
      )
      def plug_in_export_layers(run_mode, image, *args):
        ...
    c                 :    t           | <   | t          | j        <   | S rT   )_procedures_procedures_namesr`   rI   kwargss    r   procedure_wrapperz$procedure.<locals>.procedure_wrapperZ  s!    %k).7	*+r!   rn   )r   r   s   ` r   rI   rI      s%    t    
 r!   c                  H    t          j        ddt          t                     dS )z{Enables installation and running of GIMP procedures.
    
    Call this function at the end of your main plug-in file.
    N)r   rJ   _query_runrn   r!   r   rJ   rJ   a  s     
 	IdD&$'''''r!   r   r7   c                     d }t          j        | j        |||||||t          j         ||	           ||
                     |rt          j        | j        |           d S d S )Nc                     g }| r?t          | d         t          j        t          j        f          }|rt          j        |  }n| }|S )Nr   )
isinstancerC   SettingGroupcreate_params)params
pdb_paramshas_settingss      r   _get_pdb_paramsz+_install_procedure.<locals>._get_pdb_paramsu  sR    j	 !
)gow}57 7 	,f5***r!   )r   install_procedurer`   	gimpenumsPLUGINmenu_register)rI   blurbdescriptionauthorcopyright_noticedate	menu_name	menu_pathimage_types
parametersreturn_valuesr   s               r   _install_procedurer   h  s       	
oj!!om$$& & &  8
+Y777778 8r!   c                      t          j        t          j        t          j                   t
                                          D ]\  } }t          | fi | d S rT   )r   domain_registerrG   r   r   r   itemsr   r   s     r   r   r     s^    +V-BCCC(..00 . .	6--f----. .r!   c                     t          t          |          |d                   }t          t          d          rt          j                      ||  d S )Nr   gimp_ui_init)_add_gui_excepthookr   r   gimpuir   )procedure_nameprocedure_paramsrI   s      r   r   r     sX    #')9!)<> >I v~&& I    r!   c                     |t           j        k    rYt          j        t                     t          j        t          j        t          j        t          j                  } ||           S | S )N)r   r   report_uri_list)	r   RUN_INTERACTIVEr=   &set_gui_excepthook_additional_callback'_display_message_on_setting_value_erroradd_gui_excepthookrG   r~   r   )rI   run_modeadd_gui_excepthook_funcs      r   r   r     sm    9,,,	0/1 1 1 !$ 6!$2!4 !4 !4
 %$Y///r!   c                     t          | t          j                  r5t          j        t          j        t          |                               dS dS )NTF)
issubclassrC   SettingValueErrorr   messager8   safe_encode_gimpr4   )exc_type	exc_valueexc_tracebacks      r   r   r     sB    (G566 
l5)#i..99:::TUr!   )
r   r   r   r   r   r   Nr7   NN)V
__future__r   r   r   r   r   r   r   	tracebackr   realpathr|   getfilecurrentframerx   r   r   r   r   r   r   r   set_gui_excepthookr    r   future.builtinsr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r   r   	constantsr8   r9   r   r   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   __all__extendrG   rL   r   ry   r   r   r   r   r   r   rI   rJ   r   r   r   r   r   rn   r!   r   <module>r     s   S R R R R R R R R R R R  				 



    G$$RW___W_EYWEYE[E[5\5\%]%]^^ *+++ &*""  + + +%*"""+
       $ " ''//"3446GH# " " " " $ >"-"====- - - & %bgll3Df&M&M N N N1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1                         # $---&&&&&&######   $ 	..      , 
         f      .1' 1' 1'h  6 6 6*# # #0K K K4  $ Y''))+-k-//? ? ?B( ( ( (8 (8 (8 (8T. . .! ! !      iY Ys   +A2 2A<;A<                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    ri[fF2                     R   d dl mZmZmZmZ d dlZd dlZd dlZd dlZej                  j                  ej                  j                   ej                   ej                                           Z	 d dlZdZddlmZ er2 ej(                  dej                  j                  e      egddd	
       erddlmZ  ej,                  dd       d Z eej                  j1                  ed             d dlmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z- d dl.Z.d dl/Z/d dl0Z0ddl1 ddlm2Z2 ddlm3Z3 er\d dl4Z4d dl5Z5ddlm6Z6 ddlm7Z7 ddlm8Z8 ddlm9Z9 ddlm:Z: ddlm;Z; ddlm<Z< ddlm	Z	 ddlm=Z= ddlm>Z> ddlm?Z? d dlm@Z@ ddl?mAZA dd l?mBZB g d!ZCereCj                  g d"       daE G d# d$e%      ZFd% ZGd& ZHd' ZId( ZJd) ZK eG        erC e/j                         ZM e/j                         ZNd* ZOd+ ZP	 	 	 	 	 	 	 	 	 	 d1d,ZQd- ZRd. ZSd/ ZTd0 ZUyy# e$ r dZY w xY w)2    )absolute_importdivisionprint_functionunicode_literalsNTF   )logging
exceptions	error.log	pygimplib)log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title)_gui_messages)titleapp_namec                    t        j                  |       D ]t  }t         j                  j                  | |      }t         j                  j	                  |      sC|t
        j                  vsVt
        j                  j                  |       v y)ad  
  Add directory paths containing external libraries for pygimplib to `sys.path`
  so that modules from these external libraries can be imported as system
  modules (i.e. without using absolute or explicit relative imports).
  
  Modules with the same name that are already installed system-wide override the
  external library modules from `pygimplib`.
  N)oslistdirpathjoinisdirsysappend)dirpathfilenameexternal_libs_dirpaths      J/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/__init__.py%_setup_import_of_external_lib_modulesr    &   s_     **W% -hGGLL(;	ww}}*+0ESXX0U	hhoo+,-    _lib)asciibyteschrdictfilterhexinputintlistmapnextobjectoctopenpowrangeroundstrsuperzip)*)utils)version)invoker)fileformats)
invocation)gui)itemtree)objectfilter)	overwrite)r   )pdbutils)progress)setting)pdb)SettingGuiTypes)SettingTypes)r   r8   r9   configinit)r:   r;   r<   r=   r>   r?   r@   r   rA   rB   rC   rD   	proceduremainrE   rF   c                   0     e Zd Z fdZd Zd Zd Z xZS )_Configc                 :    t               j                  di        y )N_config)r5   __setattr__)self	__class__s    r   __init__z_Config.__init__   s    	G	2&r!   c                 "    || j                   |<   y NrN   )rP   namevalues      r   rO   z_Config.__setattr__   s    DLLr!   c                     || j                   vrt        dj                  |            | j                   |   }t        |      r |       S |S )Nz"configuration entry "{}" not found)rN   AttributeErrorformatcallable)rP   rV   attrs      r   __getattr__z_Config.__getattr__   sF    4<<?FFtLMM<<D~Vmkr!   c                     || j                   v S rT   rU   )rP   rV   s     r   __hasattr__z_Config.__hasattr__   s    4<<r!   )__name__
__module____qualname__rR   rO   r]   r_   __classcell__)rQ   s   @r   rL   rL   }   s    '	 r!   rL   c                      t         y d  t               a t        t         _        t               ht        j
                  j                        t         _        t         _        t        j
                  j                        t         _
        d t         _        ndt         _        t        j
                  j                  t              t         _        t        j
                  j                  t         j                        t         _
        t        j
                  j                  t              t         _        t         j                  t         _        d t         _        dt         _        d t         _         fdt         _        g t         _        t$        rdt         _        nd	t         _        t)        t                t+                t-        t                y )
Nc                 N    | ydt         j                  j                  dd      z   S )Nzgimp20-pythonzgimp-plugin-_-)rG   PLUGIN_NAMEreplace)root_plugin_dirpaths    r   _get_domain_namez&_init_config.<locals>._get_domain_name   s)    "f0088cBBBr!   c                  "    t         j                  S rT   )rG   PLUGIN_DIRPATH r!   r   <lambda>z_init_config.<locals>.<lambda>   s    &*?*? r!   gimp_pluginc                  "    t         j                  S rT   )rG   rh   rn   r!   r   ro   z_init_config.<locals>.<lambda>   s     2 2 r!   z1.0c                  |    t         j                  j                  t        j                  t        j
                  d      S )Nlocale)r   r   r   rG   PLUGINS_DIRPATHrh   rn   r!   r   ro   z_init_config.<locals>.<lambda>   s#    BGGLL//1C1CXN r!   c                              S rT   rn   rk   rj   s   r   ro   z_init_config.<locals>.<lambda>   s    /0CD r!   r	   none)rG   rL   PYGIMPLIB_DIRPATH_get_root_plugin_dirpathr   r   basename_DEFAULT_PLUGIN_NAMErm   dirnamert   DEFAULT_LOGS_DIRPATHrh   PLUGIN_TITLEPLUGIN_VERSIONLOCALE_DIRPATHDOMAIN_NAMEBUG_REPORT_URL_LIST _gimp_dependent_modules_importedLOG_MODE_init_config_builtin_init_config_from_file_init_config_builtin_delayedrv   s   @@r   _init_configr      s&    
C 9&.&02$"$''"2"23F"GF/FWW__-@AF"?F #0FGGOO,=>FWW__V-B-BCF"$''//2C"DF22&2&& O 	D&!&%"FOFOvv&r!   c                  z    t        j                         } | r%t        j                  j	                  | d   d         S y )Nr   )inspectstackr   r   r|   )frame_stacks    r   ry   ry      s/    +77??;r?1-..r!   c                    g | _         | j                   j                  | j                         t        rXt        j
                  j                  t        j                  d      }|| j                  k7  r| j                   j                  |       | j                  | _	        | j                  | _
        d| _        d| _        d| _        y )Nzplug-insz
output.logr
   2   )PLUGINS_LOG_DIRPATHSr   r}   r   r   r   r   gimp	directoryPLUGINS_LOG_STDOUT_DIRPATHPLUGINS_LOG_STDERR_DIRPATHPLUGINS_LOG_STDOUT_FILENAMEPLUGINS_LOG_STDERR_FILENAME'GIMP_CONSOLE_MESSAGE_DELAY_MILLISECONDS)rG   plugins_dirpath_alternates     r   r   r      s     "&$$V%@%@A% "T^^Z H F$?$?? !!(()BC&,&A&A&#&,&A&A&#'3&$'2&$35&0r!   c                      d } t        t        d      rt        j                  } t        t        _        	 ddlm} | t        `y | t        _        y # t        $ r 	 ddlm} n# t        $ r Y nw xY wY 7w xY w)Nc   )
config_devrG   )hasattr__builtin__r   rG    r   ImportError)orig_builtin_cplugin_configs     r   r   r      sj    .[# ]]N+-	 / "KM 
 , 
s5   A 	A1AA1	A+(A1*A++A10A1c                      fd}t         r |        _        t        j                   j                         _        t        j
                   j                         _        t        j                  j                  j                  t        j                  d j                  fd j                  fg             t        j                   j                   j                  d       t         s j                   dk7  rWt#        j$                   j                    j&                   j(                   j*                   j,                   j.                         y y )Nc                  p     j                   j                  d      r j                   S d j                   z   S )Nplug_inplug_in_)rh   
startswithr   s   r   _get_setting_source_namez>_init_config_builtin_delayed.<locals>._get_setting_source_name   s4    $$Y/&,,,,r!   session
persistentT)unicodegimp_console)r   SOURCE_NAMErC   GimpShelfSourceSESSION_SOURCEGimpParasiteSourcePERSISTENT_SOURCE	persistor	Persistorset_default_setting_sourcescollectionsOrderedDictgettextinstallr   r   r   r   
log_outputr   r   r   r~   r   )rG   r   s   ` r   r   r      s   - &13F#33F4F4FGF&99&:L:LMF;;K<S<S&''(V--.U0 =1 2 
//&$$f&;&;TJ%N)Joov22((&*L*L6IIK *Kr!   c                        fd}|S )a  Installs a function as a GIMP procedure.
    
    Use this function as a decorator over a function to be exposed to the GIMP
    procedural database (PDB).
    
    The installed procedure can then be accessed via the GIMP (PDB) and,
    optionally, from the GIMP user interface.
    
    The function name is used as the procedure name as found in the GIMP PDB.
    
    The following keyword arguments are accepted:
    
    * `blurb` - Short description of the procedure.
    
    * `description` - More detailed information about the procedure.
    
    * `author` - Author of the plug-in.
    
    * `copyright_holder` - Copyright holder of the plug-in.
    
    * `date` - Dates (usually years) at which the plug-in development was
      active.
    
    * `menu_name` - Name of the menu entry in the GIMP user interface.
    
    * `menu_path` - Path of the menu entry in the GIMP user interface.
    
    * `image_types` - Image types to which the procedure applies (e.g. RGB or
      indexed). Defaults to `'*'` (any image type).
    
    * `parameters` - Procedure parameters. This is a list of tuples of three
      elements: `(PDB type, name, description)`. Alternatively, you may pass a
      `setting.Group` instance or a list of `setting.Group` instances containing
      plug-in settings.
    
    * `return_values` - Return values of the procedure, usable when calling the
      procedure programmatically. The format of `return_values` is the same as
      `parameters`.
    
    Example:
      
      import pygimplib as pg
      
      \@pg.procedure(
        blurb='Export layers as separate images',
        author='John Doe',
        menu_name=_('E_xport Layers...'),
        menu_path='<Image>/File/Export',
        parameters=[
          (gimpenums.PDB_INT32, 'run-mode', 'The run mode'),
          (gimpenums.PDB_IMAGE, 'image', 'The current image'),
          (gimpenums.PDB_STRING, 'dirpath', 'Output directory path')]
      )
      def plug_in_export_layers(run_mode, image, *args):
        ...
    c                 @    t         | <   | t        | j                  <   | S rT   )_procedures_procedures_namesr`   rI   kwargss    r   procedure_wrapperz$procedure.<locals>.procedure_wrapperZ  s$    %k).7	**+r!   rn   )r   r   s   ` r   rI   rI      s    t
 r!   c                  D    t        j                  ddt        t               y)z{Enables installation and running of GIMP procedures.
    
    Call this function at the end of your main plug-in file.
    N)r   rJ   _query_runrn   r!   r   rJ   rJ   a  s    
 	IIdD&$'r!   c                     d }t        j                  | j                  |||||||t        j                   ||	       ||
             |r!t        j
                  | j                  |       y y )Nc                     g }| rEt        | d   t        j                  t        j                  f      }|rt        j                  |  }|S | }|S )Nr   )
isinstancerC   SettingGroupcreate_params)params
pdb_paramshas_settingss      r   _get_pdb_paramsz+_install_procedure.<locals>._get_pdb_paramsu  sR    j	!
)goow}}57,,f5*  *r!   )r   install_procedurer`   	gimpenumsPLUGINmenu_register)rI   blurbdescriptionauthorcopyright_noticedate	menu_name	menu_pathimage_types
parametersreturn_valuesr   s               r   _install_procedurer   h  sn     	
j!m$& 
++Y7 r!   c                      t        j                  t        j                  t        j                         t
        j                         D ]  \  } }t        | fi |  y rT   )r   domain_registerrG   r   r   r   itemsr   r   s     r   r   r     sH    ++V-B-BC(..0 .	6-f-.r!   c                     t        t        |    |d         }t        t        d      rt        j                           ||  y )Nr   gimp_ui_init)_add_gui_excepthookr   r   gimpuir   )procedure_nameprocedure_paramsrI   s      r   r   r     s=    #')9!)<>I v~& r!   c                     |t         j                  k(  rct        j                  t               t        j
                  t        j                  t        j                  t        j                        } ||       S | S )N)r   r   report_uri_list)	r   RUN_INTERACTIVEr=   &set_gui_excepthook_additional_callback'_display_message_on_setting_value_erroradd_gui_excepthookrG   r~   r   )rI   run_modeadd_gui_excepthook_funcs      r   r   r     sb    9,,,	00/1 !$ 6 6!!$$22!4
 %Y//r!   c                     t        | t        j                        r2t        j                  t        j                  t        |                   yy)NTF)
issubclassrC   SettingValueErrorr   messager8   safe_encode_gimpr4   )exc_type	exc_valueexc_tracebacks      r   r   r     s3    (G556
ll5))#i.9:r!   )
r   r   r   r   r   r   Nr7   NN)V
__future__r   r   r   r   r   r   r   	tracebackr   realpathr|   getfilecurrentframerx   r   r   r   r   r   r   r   set_gui_excepthookr    r   future.builtinsr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r   r   	constantsr8   r9   r   r   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   __all__extendrG   rL   r   ry   r   r   r   r   r   r   rI   rJ   r   r   r   r   r   rn   r!   r   <module>r     s   S R  	 
 GG$$RWW___W__EYWEYEYE[5\%]^ * &*"  $ '''//"346GH# " $"-""=- &bggll3Df&M N1 1 1 1 1 1      #&# $	..  , 
 f  .1'h6*#0K4  $''')+-k--/?B( (8T.!i $[  +%*"+s   1H H&%H&                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    ri[fF2                     |   S SK JrJrJrJr  S SKrS SKrS SKrS SKr\R                  R                  \R                  R                  \R                  " \R                  " 5       5      5      5      r S SKrSrSSKJr  \(       a/  \R(                  " S\R                  R                  \5      \/SSS	S
9  \(       a  SSKJr  \R,                  " SSS9  S r\" \R                  R1                  \S5      5        S SKJrJrJrJrJrJrJ r J!r!J"r"J#r#J$r$J%r%J&r&J'r'J(r(J)r)J*r*J+r+J,r,J-r-  S SK.r.S SK/r/S SK0r0SSK17  SSKJ2r2  SSKJ3r3  \(       a\  S SK4r4S SK5r5SSKJ6r6  SSKJ7r7  SSKJ8r8  SSKJ9r9  SSKJ:r:  SSKJ;r;  SSKJ<r<  SSKJ	r	  SSKJ=r=  SSKJ>r>  SSKJ?r?  S SKJ@r@  SSK?JArA  SS K?JBrB  / S!QrC\(       a  \CR                  / S"Q5        SqE " S# S$\%5      rFS% rGS& rHS' rIS( rJS) rK\G" 5         \(       aD  \/R                  " 5       rM\/R                  " 5       rNS* rOS+ rP          S1S, jrQS- rRS. rSS/ rTS0 rUgg! \ a    Sr GNf = f)2    )absolute_importdivisionprint_functionunicode_literalsNTF   )logging
exceptions	error.log	pygimplib)log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title)_gui_messages)titleapp_namec                 2   [         R                  " U 5       H}  n[         R                  R                  X5      n[         R                  R	                  U5      (       d  MH  U[
        R                  ;  d  M^  [
        R                  R                  U5        M     g)aV  
Add directory paths containing external libraries for pygimplib to `sys.path`
so that modules from these external libraries can be imported as system
modules (i.e. without using absolute or explicit relative imports).

Modules with the same name that are already installed system-wide override the
external library modules from `pygimplib`.
N)oslistdirpathjoinisdirsysappend)dirpathfilenameexternal_libs_dirpaths      J/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/__init__.py%_setup_import_of_external_lib_modulesr    &   s[     **W%hGGLL;	ww}}*++0ESXX0U	hhoo+, &    _lib)asciibyteschrdictfilterhexinputintlistmapnextobjectoctopenpowrangeroundstrsuperzip)*)utils)version)invoker)fileformats)
invocation)gui)itemtree)objectfilter)	overwrite)r   )pdbutils)progress)setting)pdb)SettingGuiTypes)SettingTypes)r   r8   r9   configinit)r:   r;   r<   r=   r>   r?   r@   r   rA   rB   rC   rD   	proceduremainrE   rF   c                   :   ^  \ rS rSrU 4S jrS rS rS rSrU =r	$ )_Config}   c                 :   > [        5       R                  S0 5        g )N_config)r5   __setattr__)self	__class__s    r   __init___Config.__init__   s    	G	2&r!   c                      X R                   U'   g NrO   )rQ   namevalues      r   rP   _Config.__setattr__   s    LLr!   c                     XR                   ;  a  [        SR                  U5      5      eU R                   U   n[        U5      (       a  U" 5       $ U$ )Nz"configuration entry "{}" not found)rO   AttributeErrorformatcallable)rQ   rX   attrs      r   __getattr___Config.__getattr__   sF    <<?FFtLMM<<D~~Vmkr!   c                     XR                   ;   $ rV   rW   )rQ   rX   s     r   __hasattr___Config.__hasattr__   s    <<r!    )
__name__
__module____qualname____firstlineno__rS   rP   r`   rc   __static_attributes____classcell__)rR   s   @r   rL   rL   }   s    '	   r!   rL   c                    ^ ^ [         b  g S m [        5       q [        [         l        [        5       mTbh  [        R
                  R                  T5      [         l        T[         l        [        R
                  R                  T5      [         l
        S [         l        OS[         l        [        R
                  R                  [        5      [         l        [        R
                  R                  [         R                  5      [         l
        [        R
                  R                  [        5      [         l        [         R                  [         l        S [         l        S[         l        S [         l        U U4S j[         l        / [         l        [$        (       a  S[         l        OS	[         l        [)        [         5        [+        5         [-        [         5        g )
Nc                 P    U c  gS[         R                  R                  SS5      -   $ )Nzgimp20-pythonzgimp-plugin-_-)rG   PLUGIN_NAMEreplace)root_plugin_dirpaths    r   _get_domain_name&_init_config.<locals>._get_domain_name   s)    "f0088cBBBr!   c                  "    [         R                  $ rV   )rG   PLUGIN_DIRPATHre   r!   r   <lambda>_init_config.<locals>.<lambda>   s
    &*?*?r!   gimp_pluginc                  "    [         R                  $ rV   )rG   rp   re   r!   r   rw   rx      s
     2 2r!   z1.0c                  |    [         R                  R                  [        R                  [        R
                  S5      $ )Nlocale)r   r   r   rG   PLUGINS_DIRPATHrp   re   r!   r   rw   rx      s!    BGGLL//1C1CXNr!   c                     > T " T5      $ rV   re   rs   rr   s   r   rw   rx      s    /0CDr!   r	   none)rG   rL   PYGIMPLIB_DIRPATH_get_root_plugin_dirpathr   r   basename_DEFAULT_PLUGIN_NAMErv   dirnamer}   DEFAULT_LOGS_DIRPATHrp   PLUGIN_TITLEPLUGIN_VERSIONLOCALE_DIRPATHDOMAIN_NAMEBUG_REPORT_URL_LIST _gimp_dependent_modules_importedLOG_MODE_init_config_builtin_init_config_from_file_init_config_builtin_delayedr   s   @@r   _init_configr      s)    
C 9&.&02$"$''"2"23F"GF/FWW__-@AF"?F #0FGGOO,=>FWW__V-B-BCF"$''//2C"DF22&2&& O 	D&!&%%"FOFOvv&r!   c                      [         R                  " 5       n U (       a%  [        R                  R	                  U S   S   5      $ g )Nr   )inspectstackr   r   r   )frame_stacks    r   r   r      s/    +77??;r?1-..r!   c                    / U l         U R                   R                  U R                  5        [        (       aX  [        R
                  R                  [        R                  S5      nXR                  :w  a  U R                   R                  U5        U R                  U l	        U R                  U l
        SU l        SU l        SU l        g )Nzplug-insz
output.logr
   2   )PLUGINS_LOG_DIRPATHSr   r   r   r   r   r   gimp	directoryPLUGINS_LOG_STDOUT_DIRPATHPLUGINS_LOG_STDERR_DIRPATHPLUGINS_LOG_STDOUT_FILENAMEPLUGINS_LOG_STDERR_FILENAME'GIMP_CONSOLE_MESSAGE_DELAY_MILLISECONDS)rG   plugins_dirpath_alternates     r   r   r      s     "&$$V%@%@A%% "T^^Z H $?$?? !!(()BC&,&A&A&#&,&A&A&#'3&$'2&$35&0r!   c                      S n [        [        S5      (       a  [        R                  n [        [        l         SSKJn  U c  [        ?g U [        l        g ! [         a     SSKJn   N)! [         a      N6f = ff = f)Nc   )
config_devrG   )hasattr__builtin__r   rG    r   ImportError)orig_builtin_cplugin_configs     r   r   r      sm    .[# ]]N+-	 / "KM 
 , 
s)   A 
A9A''
A51A94A55A9c                   ^  U 4S jn[         (       a  U" 5       T l        [        R                  " T R                  5      T l        [        R
                  " T R                  5      T l        [        R                  R                  R                  [        R                  " ST R                  4ST R                  4/5      5        [        R                  " T R                  T R                  SS9  [         (       d  T R                   S:w  aX  ["        R$                  " T R                   T R&                  T R(                  T R*                  T R,                  T R.                  5        g g )Nc                  z   > T R                   R                  S5      (       a  T R                   $ ST R                   -   $ )Nplug_inplug_in_)rp   
startswithr   s   r   _get_setting_source_name>_init_config_builtin_delayed.<locals>._get_setting_source_name   s7    $$Y//&,,,,r!   session
persistentT)unicodegimp_console)r   SOURCE_NAMErC   GimpShelfSourceSESSION_SOURCEGimpParasiteSourcePERSISTENT_SOURCE	persistor	Persistorset_default_setting_sourcescollectionsOrderedDictgettextinstallr   r   r   r   
log_outputr   r   r   r   r   )rG   r   s   ` r   r   r      s   - &%13F#33F4F4FGF&99&:L:LMF;;K<S<S&''(V--.U0 =1 2 
//&$$f&;&;TJ%%N)Joov22((&*L*L6IIK *Kr!   c                     ^  U 4S jnU$ )a  Installs a function as a GIMP procedure.

Use this function as a decorator over a function to be exposed to the GIMP
procedural database (PDB).

The installed procedure can then be accessed via the GIMP (PDB) and,
optionally, from the GIMP user interface.

The function name is used as the procedure name as found in the GIMP PDB.

The following keyword arguments are accepted:

* `blurb` - Short description of the procedure.

* `description` - More detailed information about the procedure.

* `author` - Author of the plug-in.

* `copyright_holder` - Copyright holder of the plug-in.

* `date` - Dates (usually years) at which the plug-in development was
  active.

* `menu_name` - Name of the menu entry in the GIMP user interface.

* `menu_path` - Path of the menu entry in the GIMP user interface.

* `image_types` - Image types to which the procedure applies (e.g. RGB or
  indexed). Defaults to `'*'` (any image type).

* `parameters` - Procedure parameters. This is a list of tuples of three
  elements: `(PDB type, name, description)`. Alternatively, you may pass a
  `setting.Group` instance or a list of `setting.Group` instances containing
  plug-in settings.

* `return_values` - Return values of the procedure, usable when calling the
  procedure programmatically. The format of `return_values` is the same as
  `parameters`.

Example:
  
  import pygimplib as pg
  
  \@pg.procedure(
    blurb='Export layers as separate images',
    author='John Doe',
    menu_name=_('E_xport Layers...'),
    menu_path='<Image>/File/Export',
    parameters=[
      (gimpenums.PDB_INT32, 'run-mode', 'The run mode'),
      (gimpenums.PDB_IMAGE, 'image', 'The current image'),
      (gimpenums.PDB_STRING, 'dirpath', 'Output directory path')]
  )
  def plug_in_export_layers(run_mode, image, *args):
    ...
c                 @   > T[         U '   U [        U R                  '   U $ rV   )_procedures_procedures_namesrf   rI   kwargss    r   procedure_wrapper$procedure.<locals>.procedure_wrapperZ  s$    %k).7	**+r!   re   )r   r   s   ` r   rI   rI      s    t
 r!   c                  F    [         R                  " SS[        [        5        g)zoEnables installation and running of GIMP procedures.

Call this function at the end of your main plug-in file.
N)r   rJ   _query_runre   r!   r   rJ   rJ   a  s    
 	IIdD&$'r!   c                     S n[         R                  " U R                  UUUUUUU[        R                  U" U	5      U" U
5      5        U(       a"  [         R
                  " U R                  U5        g g )Nc                     / nU (       aK  [        U S   [        R                  [        R                  45      nU(       a  [        R                  " U 6 nU$ U nU$ )Nr   )
isinstancerC   SettingGroupcreate_params)params
pdb_paramshas_settingss      r   _get_pdb_params+_install_procedure.<locals>._get_pdb_paramsu  sR    j	!
)goow}}57,,f5*  *r!   )r   install_procedurerf   	gimpenumsPLUGINmenu_register)rI   blurbdescriptionauthorcopyright_noticedate	menu_name	menu_pathimage_types
parametersreturn_valuesr   s               r   _install_procedurer   h  sn     	
j!m$& 
++Y7 r!   c                      [         R                  " [        R                  [        R                  5        [
        R                  5        H  u  p[        U 40 UD6  M     g rV   )r   domain_registerrG   r   r   r   itemsr   r   s     r   r   r     sA    ++V-B-BC(..0	-f- 1r!   c                     [        [        U    US   5      n[        [        S5      (       a  [        R                  " 5         U" U6   g )Nr   gimp_ui_init)_add_gui_excepthookr   r   gimpuir   )procedure_nameprocedure_paramsrI   s      r   r   r     s@    #')9!)<>I v~&& r!   c                     U[         R                  :X  ab  [        R                  " [        5        [        R
                  " [        R                  [        R                  [        R                  S9nU" U 5      $ U $ )N)r   r   report_uri_list)	r   RUN_INTERACTIVEr=   &set_gui_excepthook_additional_callback'_display_message_on_setting_value_erroradd_gui_excepthookrG   r   r   )rI   run_modeadd_gui_excepthook_funcs      r   r   r     sb    9,,,	00/1 !$ 6 6!!$$22!4
 %Y//r!   c                     [        U [        R                  5      (       a4  [        R                  " [
        R                  " [        U5      5      5        gg)NTF)
issubclassrC   SettingValueErrorr   messager8   safe_encode_gimpr4   )exc_type	exc_valueexc_tracebacks      r   r   r     s6    (G5566
ll5))#i.9:r!   )
r   r   r   r   r   r   Nr7   NN)V
__future__r   r   r   r   r   r   r   	tracebackr   realpathr   getfilecurrentframer   r   r   r   r   r   r   r   set_gui_excepthookr    r   future.builtinsr#   r$   r%   r&   r'   r(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r   r   r   	constantsr8   r9   r   r   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   __all__extendrG   rL   r   r   r   r   r   r   r   r   rI   rJ   r   r   r   r   r   re   r!   r   <module>r     s   S R  	 
 GG$$RWW__W__WEYEYE[5\%]^ * &*"  $ 
''//"346GH# " $""=- &bggll3Df&M N1 1 1 1 1 1      #&# $	..  , 
 f  .1'h6*#0K4  $'')+!--/?B( (8T.!i $[  +%*"+s   1H/ /H;:H;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  
    d@$                         d Z ddlmZmZmZmZ eZddlZddl	Z	ddl
Z
ddlZddlZddlmZ dZda	 	 ddZd	 ZddZd Zd Z G d de          Z G d de          ZdS )zLogging-related classes.    )absolute_importdivisionprint_functionunicode_literalsN   )
_path_dirs)none
exceptionsfilesgimp_console c                 :   t          |            | dk    rdS | dk    rt          |||           dS | dk    r\t          ||          }|t          ||          t          _        t          ||          }|t          ||          t          _        dS dS | dk    rIddlm} |	                    |          t          _        |	                    d	|
          t          _        dS t          d                    | d                    t                                        )a  
  Enable logging of output.
  
  Parameters:
  
  * `log_mode` - The log mode. Possible values:
    
    * 'none' - Do not log anything.
    
    * 'exceptions' - Only log exceptions to the error log file.
    
    * 'files' - Redirect `stdout` and `stderr` to log files.
    
    * 'gimp_console' - Redirect `stdout` and `stderr` to the GIMP error console.
  
  * `log_dirpaths` - List of directory paths for log files. If the first path is
    invalid or permission to write is denied, subsequent directories are used.
    For the `'gimp_console'` mode, this parameter has no effect.
  
  * `log_stdout_filename` - Filename of the log file to write standard output
    to. Applies to the `'files'` mode only.
  
  * `log_stderr_filename` - Filename of the log file to write error output to.
    Applies to the `'exceptions'` and `'files'` modes only.
  
  * `log_header_title` - Optional title in the log header, written before the
    first output to the log files. Applies to the `'exceptions'` and `'files'`
    modes only.
  
  * `gimp_console_message_delay_milliseconds` - The delay to display messages to
    the GIMP console in milliseconds. Only applies to the `'gimp_console'` mode.
  r	   Nr
   r   r   r   )pdbutils)message_delay_millisecondszError: )message_prefixr   z)invalid log mode "{}"; allowed values: {}z, )_restore_orig_state"_redirect_exception_output_to_filecreate_log_fileSimpleLoggersysstdoutstderrr   r   GimpMessageFile
ValueErrorformatjoin
_LOG_MODES)	log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title'gimp_console_message_delay_millisecondsstdout_filestderr_file
pgpdbutilss	            I/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/logging.py
log_outputr(      sX   N h
F&')9; ; ; ; ;7!,0CDDK-=>>cj!,0CDDK-=>>cjjj >!!((((((++!H , J JCJ++!H , J JCJJJ @GG		*%%' ' ( ( (    c           	          d                     dd| t          t          j                                                  df          S )N
r   zP================================================================================)r   strdatetimenow)r"   s    r'   get_log_headerr/   e   s8    	B"2C8I8M8M8O8O4P4PRVW	X	XXr)   ac                     d}| D ]o}	 t          j        |           n# t          $ r Y $w xY w	 t          j        t
          j                            ||          |d          } n# t          $ r Y lw xY w|S )z
  Create a log file in the first file path that can be written to.
  
  Return the log file upon successful creation, `None` otherwise.
  Nzutf-8)encoding)	r   	make_dirsOSErrorioopenospathr   IOError)r   log_filenamemodelog_filelog_dirpaths        r'   r   r   i   s     (!  k;''''   hk<@@$QXYYYh e    h
 
/s   
**5A%%
A21A2c                 t   t           t          j        t          j        fD ]T}|Pt	          |d          r@|t          j        t          j        fvr&	 |                                 D# t          $ r Y Pw xY wUd a t          j	        t          _
        t          j        t          _        t          j        t          _        d S )Nclose)_exception_loggerr   r   r   hasattr
__stdout__
__stderr__r?   r9   __excepthook__
excepthook)r   file_s     r'   r   r      s     "3:sz:  eE7## 	#.#.999    %#.~#*~#***s   A##
A0/A0c                 <      fd}d |t           _        d S )Nc                     t                    }|+t          |          a | ||           t          _        d S t          j        t          _        d S N)r   r   r@   r   rE   rD   )exc_type	exc_valueexc_traceback_exception_log_filer   log_exceptionr:   r"   s       r'   ,create_file_upon_exception_and_log_exceptionzX_redirect_exception_output_to_file.<locals>.create_file_upon_exception_and_log_exception   sZ     *,EE&&':<LMMmHi777$cnnn)cnnnr)   c           	          t                               d                    t          j        | ||                               d S )Nr   )r@   writer   	tracebackformat_exception)rJ   rK   rL   s      r'   rN   z9_redirect_exception_output_to_file.<locals>.log_exception   sI     ggi(9mLLMMO O O O Or)   )r   rE   )r   r:   r"   rO   rN   s   ``` @r'   r   r      sN    * * * * * * * *O O O @#...r)   c                   0    e Zd ZdZd Zd Zd Zd Zd ZdS )r   zO
  This class wraps a file object to write a header before the first output.
  c                 "    || _         || _        d S rI   )	_log_file_log_header_title)selfrF   r"   s      r'   __init__zSimpleLogger.__init__   s    DN-Dr)   c                     | j         r'|                     t          | j                              |                     |           | j        | _        d S rI   )rW   _writer/   rQ   rX   datas     r'   rQ   zSimpleLogger.write   sI     :
kk.!788999KKDJJJr)   c                 |    | j                             t          |                     |                                  d S rI   )rV   rQ   r,   flushr\   s     r'   r[   zSimpleLogger._write   s/    NT###JJLLLLLr)   c                 8    | j                                          d S rI   )rV   r_   rX   s    r'   r_   zSimpleLogger.flush       Nr)   c                 8    | j                                          d S rI   )rV   r?   ra   s    r'   r?   zSimpleLogger.close   rb   r)   N)	__name__
__module____qualname____doc__rY   rQ   r[   r_   r?    r)   r'   r   r      si         . . .          r)   r   c                       e Zd ZdZ	 ddZd Zed             Zej        d             Zd	 Z	d
 Z
d Zd Zd Zd Zd ZdS )Teea  
  This class copies `stdout` or `stderr` output to a specified file,
  much like the Unix `tee` command.
  
  This class acts as a file-like object containing the `write()` and `flush()`
  methods.
  
  Attributes:
  
  * `stream` - Either `sys.stdout` or `sys.stderr`. Other objects are invalid
    and raise `ValueError`.
    
  * `log_header_title` - Header text to write when writing into the file
    for the first time.
  NTFc                     t           j        dt           j        di| _        ||nd| _        || _        d| _        d| _        d| _        d| _	        d| _
        || _        |r|                     |           dS dS )a   
    Parameters:
    
    * `file_` - File or file-like object to write to.
    
    * `start` - If `True`, start `Tee` upon instantiation. To start later, pass
      `start=False` and call `start()` when desired.
    
    * `flush_output` - If `True`, flush output after each write.
    r   r   Nr   F)r   r   r   _streamsr"   flush_output_file_is_running_orig_stream_stream_name_streamstreamstart)rX   rs   rF   r"   rt   rm   s         r'   rY   zTee.__init__   s     Z3:x@DM0@0L,,RTD$DDJDDDDLDK 
jj r)   c                 Z    |                                  r|                                  d S d S rI   )
is_runningstopra   s    r'   __del__zTee.__del__   s/     
iikkkkk r)   c                     | j         S rI   )rr   ra   s    r'   rs   z
Tee.stream   s
    <r)   c                 h    || _         || j        v r| j        |         | _        d S t          d          )Nz0invalid stream; must be sys.stdout or sys.stderr)rr   rl   rq   r   )rX   values     r'   rs   z
Tee.stream  s:    DL-.dIJJJr)   c                 p    | j         | _        t          t          | j        |            || _        d| _        dS )z
    Start `Tee` if not started during the object instantiation.
    
    Parameters:
    
    * `file_` - File or file-like object to write to.
    TN)rs   rp   setattrr   rq   rn   ro   )rX   rF   s     r'   rt   z	Tee.start
  s8     DC"D)))DJDr)   c                     t          t          | j        | j                   | j                                         d| _        d| _        dS )z4
    Stop `Tee`, i.e. stop writing to the file.
    NF)r}   r   rq   rp   rn   r?   ro   ra   s    r'   rw   zTee.stop  sE     C"D$5666JDJDr)   c                     | j         S )zV
    Return `True` if `Tee` is running (i.e. writing to file), `False` otherwise.
    )ro   ra   s    r'   rv   zTee.is_running"  s     r)   c                     | j         r,| j                            t          | j                              |                     |           | j        s| j        | _        dS | j        | _        dS )z
    Write output to the stream and the specified file.
    
    If `log_header_title` is not empty, write the log header before the first
    output.
    N)r"   rn   rQ   r/   _write_with_flushrm   r[   r\   s     r'   rQ   z	Tee.write(  sj      >
j~d&;<<===4    *;djjj)djjjr)   c                 n    | j                             |           | j                            |           d S rI   )rn   rQ   rr   r\   s     r'   r[   z
Tee._write9  s4    JTLtr)   c                     | j                             |           | j                                          | j                            |           | j                                         d S rI   )rn   rQ   r_   rr   r\   s     r'   r   zTee._write_with_flush=  s\    JTJLtLr)   c                 j    | j                                          | j                                         d S rI   )rn   r_   rr   ra   s    r'   r_   z	Tee.flushC  s0    JLr)   )NTF)rd   re   rf   rg   rY   rx   propertyrs   setterrt   rw   rv   rQ   r[   r   r_   rh   r)   r'   rj   rj      s         " NS   :     8 
=K K =K      * * *"        r)   rj   )r   r   )r0   )rg   
__future__r   r   r   r   unicoder,   r-   r5   r7   r   rR   r   r   r   r@   r(   r/   r   r   r   objectr   rj   rh   r)   r'   <module>r      sX     S R R R R R R R R R R R  				 				 



           =
  ./C( C( C( C(LY Y Y   0  (@ @ @2    6   <y y y y y& y y y y yr)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    ri[f@$                         d Z ddlmZmZmZmZ eZddlZddl	Z	ddl
Z
ddlZddlZddlmZ dZda	 	 ddZd Zdd	Zd
 Zd Z G d de      Z G d de      Zy)zLogging-related classes.    )absolute_importdivisionprint_functionunicode_literalsN   )
_path_dirs)none
exceptionsfilesgimp_consolec                    t        |        | dk(  ry| dk(  rt        |||       y| dk(  rHt        ||      }|t        ||      t        _        t        ||      }|t        ||      t        _        yy| dk(  r>ddlm} |j                  |      t        _        |j                  d	|
      t        _        yt        dj                  | dj                  t                          )a  
  Enable logging of output.
  
  Parameters:
  
  * `log_mode` - The log mode. Possible values:
    
    * 'none' - Do not log anything.
    
    * 'exceptions' - Only log exceptions to the error log file.
    
    * 'files' - Redirect `stdout` and `stderr` to log files.
    
    * 'gimp_console' - Redirect `stdout` and `stderr` to the GIMP error console.
  
  * `log_dirpaths` - List of directory paths for log files. If the first path is
    invalid or permission to write is denied, subsequent directories are used.
    For the `'gimp_console'` mode, this parameter has no effect.
  
  * `log_stdout_filename` - Filename of the log file to write standard output
    to. Applies to the `'files'` mode only.
  
  * `log_stderr_filename` - Filename of the log file to write error output to.
    Applies to the `'exceptions'` and `'files'` modes only.
  
  * `log_header_title` - Optional title in the log header, written before the
    first output to the log files. Applies to the `'exceptions'` and `'files'`
    modes only.
  
  * `gimp_console_message_delay_milliseconds` - The delay to display messages to
    the GIMP console in milliseconds. Only applies to the `'gimp_console'` mode.
  r	   Nr
   r   r   r   )pdbutils)message_delay_millisecondszError: )message_prefixr   z)invalid log mode "{}"; allowed values: {}z, )_restore_orig_state"_redirect_exception_output_to_filecreate_log_fileSimpleLoggersysstdoutstderr r   GimpMessageFile
ValueErrorformatjoin
_LOG_MODES)	log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title'gimp_console_message_delay_millisecondsstdout_filestderr_file
pgpdbutilss	            I/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/logging.py
log_outputr(      s    N h
&')9;7!,0CDK-=>cj!,0CDK-=>cj >!(++!H , JCJ++!H , JCJ @GG		*%' ( (    c           	      x    dj                  dd| t        t        j                  j                               df      S )N
r   zP================================================================================)r   strdatetimenow)r"   s    r'   get_log_headerr/   e   s2    	B"2C8I8I8M8M8O4PRVW	XXr)   c                     d}| D ]Q  }	 t        j                  |       	 t        j                  t
        j                  j                  ||      |d      } |S  |S # t        $ r Y aw xY w# t        $ r Y pw xY w)z
  Create a log file in the first file path that can be written to.
  
  Return the log file upon successful creation, `None` otherwise.
  Nzutf-8)encoding)	r   	make_dirsOSErrorioopenospathr   IOError)r   log_filenamemodelog_filelog_dirpaths        r'   r   r   i   s     (! k;'k<@$QXYh 	/ 
/  
  s"   A6A*	A'&A'*	A65A6c                    t         t        j                  t        j                  fD ]F  }|t	        |d      s|t        j
                  t        j                  fvs6	 |j                          H d a t        j                  t        _
        t        j
                  t        _        t        j                  t        _        y # t        $ r Y w xY w)Nclose)_exception_loggerr   r   r   hasattr
__stdout__
__stderr__r>   r8   __excepthook__
excepthook)r   file_s     r'   r   r      s     "3::szz: eE7##..#..99 %%#.~~#*~~#*  s   B==	C	C	c                 8      fd}d |t         _        y )Nc                     t              }|"t        |      a | ||       t        _        y t        j
                  t        _        y N)r   r   r?   r   rD   rC   )exc_type	exc_valueexc_traceback_exception_log_filer   log_exceptionr9   r"   s       r'   ,create_file_upon_exception_and_log_exceptionzX_redirect_exception_output_to_file.<locals>.create_file_upon_exception_and_log_exception   sG     *,E&&':<LMHi7$cn))cnr)   c           	      v    t         j                  dj                  t        j                  | ||                   y )Nr   )r?   writer   	tracebackformat_exception)rI   rJ   rK   s      r'   rM   z9_redirect_exception_output_to_file.<locals>.log_exception   s.     ggi((9mLMOr)   )r   rD   )r   r9   r"   rN   rM   s   ``` @r'   r   r      s    *O @#.r)   c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)r   zO
  This class wraps a file object to write a header before the first output.
  c                      || _         || _        y rH   )	_log_file_log_header_title)selfrE   r"   s      r'   __init__zSimpleLogger.__init__   s    DN-Dr)   c                     | j                   r$| j                  t        | j                                | j                  |       | j                  | _        y rH   )rV   _writer/   rP   rW   datas     r'   rP   zSimpleLogger.write   s9    
kk.!7!789KKDJr)   c                 l    | j                   j                  t        |             | j                          y rH   )rU   rP   r,   flushr[   s     r'   rZ   zSimpleLogger._write   s!    NNT#JJLr)   c                 8    | j                   j                          y rH   )rU   r^   rW   s    r'   r^   zSimpleLogger.flush       NNr)   c                 8    | j                   j                          y rH   )rU   r>   r`   s    r'   r>   zSimpleLogger.close   ra   r)   N)	__name__
__module____qualname____doc__rX   rP   rZ   r^   r>    r)   r'   r   r      s     .r)   r   c                   ~    e Zd ZdZ	 ddZd Zed        Zej                  d        Zd Z	d Z
d	 Zd
 Zd Zd Zd Zy)Teea  
  This class copies `stdout` or `stderr` output to a specified file,
  much like the Unix `tee` command.
  
  This class acts as a file-like object containing the `write()` and `flush()`
  methods.
  
  Attributes:
  
  * `stream` - Either `sys.stdout` or `sys.stderr`. Other objects are invalid
    and raise `ValueError`.
    
  * `log_header_title` - Header text to write when writing into the file
    for the first time.
  Nc                     t         j                  dt         j                  di| _        ||nd| _        || _        d| _        d| _        d| _        d| _	        d| _
        || _        |r| j                  |       yy)a   
    Parameters:
    
    * `file_` - File or file-like object to write to.
    
    * `start` - If `True`, start `Tee` upon instantiation. To start later, pass
      `start=False` and call `start()` when desired.
    
    * `flush_output` - If `True`, flush output after each write.
    r   r   Nr   F)r   r   r   _streamsr"   flush_output_file_is_running_orig_stream_stream_name_streamstreamstart)rW   rr   rE   r"   rs   rl   s         r'   rX   zTee.__init__   sv     ZZ3::x@DM0@0L,RTD$DDJDDDDLDK
jj r)   c                 F    | j                         r| j                          y y rH   )
is_runningstopr`   s    r'   __del__zTee.__del__   s    
iik r)   c                     | j                   S rH   )rq   r`   s    r'   rr   z
Tee.stream   s    <<r)   c                 l    || _         || j                  v r| j                  |   | _        y t        d      )Nz0invalid stream; must be sys.stdout or sys.stderr)rq   rk   rp   r   )rW   values     r'   rr   z
Tee.stream  s2    DL--.dIJJr)   c                 x    | j                   | _        t        t        | j                  |        || _        d| _        y)z
    Start `Tee` if not started during the object instantiation.
    
    Parameters:
    
    * `file_` - File or file-like object to write to.
    TN)rr   ro   setattrr   rp   rm   rn   )rW   rE   s     r'   rs   z	Tee.start
  s1     DC""D)DJDr)   c                     t        t        | j                  | j                         | j                  j                          d| _        d| _        y)z4
    Stop `Tee`, i.e. stop writing to the file.
    NF)r|   r   rp   ro   rm   r>   rn   r`   s    r'   rv   zTee.stop  s;     C""D$5$56JJDJDr)   c                     | j                   S )zV
    Return `True` if `Tee` is running (i.e. writing to file), `False` otherwise.
    )rn   r`   s    r'   ru   zTee.is_running"  s     r)   c                     | j                   r.| j                  j                  t        | j                                | j	                  |       | j
                  s| j                  | _        y| j                  | _        y)z
    Write output to the stream and the specified file.
    
    If `log_header_title` is not empty, write the log header before the first
    output.
    N)r"   rm   rP   r/   _write_with_flushrl   rZ   r[   s     r'   rP   z	Tee.write(  sY     
jj~d&;&;<=4 ;;dj))djr)   c                 p    | j                   j                  |       | j                  j                  |       y rH   )rm   rP   rq   r[   s     r'   rZ   z
Tee._write9  s&    JJTLLtr)   c                     | j                   j                  |       | j                   j                          | j                  j                  |       | j                  j                          y rH   )rm   rP   r^   rq   r[   s     r'   r   zTee._write_with_flush=  sF    JJTJJLLtLLr)   c                 l    | j                   j                          | j                  j                          y rH   )rm   r^   rq   r`   s    r'   r^   z	Tee.flushC  s"    JJLLr)   )NTF)rc   rd   re   rf   rX   rw   propertyrr   setterrs   rv   ru   rP   rZ   r   r^   rg   r)   r'   ri   ri      si    " NS:   
==K K*"r)   ri   )r   r   )a)rf   
__future__r   r   r   r   unicoder,   r-   r4   r6   r   rQ   r   r   r   r?   r(   r/   r   r   r   objectr   ri   rg   r)   r'   <module>r      sv     S R  	 	 
   =
  ./C(LY0(@26 <y& yr)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
    ri[f@$                         S r SSKJrJrJrJr  \rSSKrSSK	r	SSK
r
SSKrSSKrSSKJr  SrSq  SS jrS rSS	 jrS
 rS r " S S\5      r " S S\5      rg)zLogging-related classes.    )absolute_importdivisionprint_functionunicode_literalsN   )
_path_dirs)none
exceptionsfilesgimp_consolec                    [        U 5        U S:X  a  gU S:X  a  [        XU5        gU S:X  aF  [        X5      nUb  [        Xd5      [        l        [        X5      nUb  [        Xt5      [        l        ggU S:X  a8  SSKJn  UR                  US9[        l        UR                  S	US
9[        l        g[        SR                  U SR                  [        5      5      5      e)ao  
Enable logging of output.

Parameters:

* `log_mode` - The log mode. Possible values:
  
  * 'none' - Do not log anything.
  
  * 'exceptions' - Only log exceptions to the error log file.
  
  * 'files' - Redirect `stdout` and `stderr` to log files.
  
  * 'gimp_console' - Redirect `stdout` and `stderr` to the GIMP error console.

* `log_dirpaths` - List of directory paths for log files. If the first path is
  invalid or permission to write is denied, subsequent directories are used.
  For the `'gimp_console'` mode, this parameter has no effect.

* `log_stdout_filename` - Filename of the log file to write standard output
  to. Applies to the `'files'` mode only.

* `log_stderr_filename` - Filename of the log file to write error output to.
  Applies to the `'exceptions'` and `'files'` modes only.

* `log_header_title` - Optional title in the log header, written before the
  first output to the log files. Applies to the `'exceptions'` and `'files'`
  modes only.

* `gimp_console_message_delay_milliseconds` - The delay to display messages to
  the GIMP console in milliseconds. Only applies to the `'gimp_console'` mode.
r	   Nr
   r   r   r   )pdbutils)message_delay_millisecondszError: )message_prefixr   z)invalid log mode "{}"; allowed values: {}z, )_restore_orig_state"_redirect_exception_output_to_filecreate_log_fileSimpleLoggersysstdoutstderr r   GimpMessageFile
ValueErrorformatjoin
_LOG_MODES)	log_modelog_dirpathslog_stdout_filenamelog_stderr_filenamelog_header_title'gimp_console_message_delay_millisecondsstdout_filestderr_file
pgpdbutilss	            I/home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/logging.py
log_outputr(      s    N h
&)9;7!,DK>cj!,DK>cj >!(++!H , JCJ++!H , JCJ @GG		*%' ( (    c           	      x    SR                  SSU [        [        R                  R                  5       5      S45      $ )N
r   zP================================================================================)r   strdatetimenow)r"   s    r'   get_log_headerr/   e   s2    	B"2C8I8I8M8M8O4PRVW	XXr)   c                     SnU  HO  n [         R                  " U5         [        R                  " [
        R                  R                  XA5      USS9n  U$    U$ ! [         a     Mb  f = f! [         a     Ms  f = f)z
Create a log file in the first file path that can be written to.

Return the log file upon successful creation, `None` otherwise.
Nzutf-8)encoding)	r   	make_dirsOSErrorioopenospathr   IOError)r   log_filenamemodelog_filelog_dirpaths        r'   r   r   i   s     (!k;'k@$QXYh 	/ " 
/  
  s"   A3A+
A('A(+
A98A9c                    [         [        R                  [        R                  4 HR  nUc  M  [	        US5      (       d  M  U[        R
                  [        R                  4;  d  MA   UR                  5         MT     S q [        R                  [        l
        [        R
                  [        l        [        R                  [        l        g ! [         a     M  f = f)Nclose)_exception_loggerr   r   r   hasattr
__stdout__
__stderr__r>   r8   __excepthook__
excepthook)r   file_s     r'   r   r      s     "3::szz:eE7###..#..99 ; %%#.~~#*~~#*  s   (C


CCc                 :   ^ ^^^ U UUU4S jnS mU[         l        g )Nc                    > [        TT5      nUb!  [        UT5      qT" XU5        T[        l        g [        R
                  [        l        g N)r   r   r?   r   rD   rC   )exc_type	exc_valueexc_traceback_exception_log_filer   log_exceptionr9   r"   s       r'   ,create_file_upon_exception_and_log_exceptionX_redirect_exception_output_to_file.<locals>.create_file_upon_exception_and_log_exception   sE     *,E&&':<LMH7$cn))cnr)   c           	      v    [         R                  SR                  [        R                  " XU5      5      5        g )Nr   )r?   writer   	tracebackformat_exception)rI   rJ   rK   s      r'   rM   9_redirect_exception_output_to_file.<locals>.log_exception   s,     ggi((mLMOr)   )r   rD   )r   r9   r"   rN   rM   s   ``` @r'   r   r      s    * *O @#.r)   c                   6    \ rS rSrSrS rS rS rS rS r	Sr
g	)
r      zK
This class wraps a file object to write a header before the first output.
c                     Xl         X l        g rH   )	_log_file_log_header_title)selfrE   r"   s      r'   __init__SimpleLogger.__init__   s    N-r)   c                     U R                   (       a$  U R                  [        U R                   5      5        U R                  U5        U R                  U l        g rH   )rY   _writer/   rQ   rZ   datas     r'   rQ   SimpleLogger.write   s9    
kk.!7!789KKDJr)   c                 l    U R                   R                  [        U5      5        U R                  5         g rH   )rX   rQ   r,   flushr_   s     r'   r^   SimpleLogger._write   s!    NNT#JJLr)   c                 8    U R                   R                  5         g rH   )rX   rc   rZ   s    r'   rc   SimpleLogger.flush       NNr)   c                 8    U R                   R                  5         g rH   )rX   r>   rf   s    r'   r>   SimpleLogger.close   rh   r)   )rX   rY   rQ   N)__name__
__module____qualname____firstlineno____doc__r[   rQ   r^   rc   r>   __static_attributes__ r)   r'   r   r      s     .r)   r   c                       \ rS rSrSr SS jrS r\S 5       r\R                  S 5       rS r
S	 rS
 rS rS rS rS rSrg)Tee   a  
This class copies `stdout` or `stderr` output to a specified file,
much like the Unix `tee` command.

This class acts as a file-like object containing the `write()` and `flush()`
methods.

Attributes:

* `stream` - Either `sys.stdout` or `sys.stderr`. Other objects are invalid
  and raise `ValueError`.
  
* `log_header_title` - Header text to write when writing into the file
  for the first time.
Nc                     [         R                  S[         R                  S0U l        Ub  UOSU l        XPl        SU l        SU l        SU l        SU l	        SU l
        Xl        U(       a  U R                  U5        gg)z
Parameters:

* `file_` - File or file-like object to write to.

* `start` - If `True`, start `Tee` upon instantiation. To start later, pass
  `start=False` and call `start()` when desired.

* `flush_output` - If `True`, flush output after each write.
r   r   Nr   F)r   r   r   _streamsr"   flush_output_file_is_running_orig_stream_stream_name_streamstreamstart)rZ   r}   rE   r"   r~   rw   s         r'   r[   Tee.__init__   sr     ZZ3::x@DM0@0L,RTD$DJDDDDLK
jj r)   c                 P    U R                  5       (       a  U R                  5         g g rH   )
is_runningstoprf   s    r'   __del__Tee.__del__   s    
iik r)   c                     U R                   $ rH   )r|   rf   s    r'   r}   
Tee.stream   s    <<r)   c                 l    Xl         XR                  ;   a  U R                  U   U l        g [        S5      e)Nz0invalid stream; must be sys.stdout or sys.stderr)r|   rv   r{   r   )rZ   values     r'   r}   r     s.    L--.dIJJr)   c                 v    U R                   U l        [        [        U R                  U 5        Xl        SU l        g)z}
Start `Tee` if not started during the object instantiation.

Parameters:

* `file_` - File or file-like object to write to.
TN)r}   rz   setattrr   r{   rx   ry   )rZ   rE   s     r'   r~   	Tee.start
  s/     DC""D)JDr)   c                     [        [        U R                  U R                  5        U R                  R                  5         SU l        SU l        g)z,
Stop `Tee`, i.e. stop writing to the file.
NF)r   r   r{   rz   rx   r>   ry   rf   s    r'   r   Tee.stop  s;     C""D$5$56JJDJDr)   c                     U R                   $ )zN
Return `True` if `Tee` is running (i.e. writing to file), `False` otherwise.
)ry   rf   s    r'   r   Tee.is_running"  s     r)   c                    U R                   (       a.  U R                  R                  [        U R                   5      5        U R	                  U5        U R
                  (       d  U R                  U l        gU R                  U l        g)z
Write output to the stream and the specified file.

If `log_header_title` is not empty, write the log header before the first
output.
N)r"   rx   rQ   r/   _write_with_flushrw   r^   r_   s     r'   rQ   	Tee.write(  sY     
jj~d&;&;<=4 ;;dj))djr)   c                 p    U R                   R                  U5        U R                  R                  U5        g rH   )rx   rQ   r|   r_   s     r'   r^   
Tee._write9  s&    JJTLLtr)   c                     U R                   R                  U5        U R                   R                  5         U R                  R                  U5        U R                  R                  5         g rH   )rx   rQ   rc   r|   r_   s     r'   r   Tee._write_with_flush=  sF    JJTJJLLtLLr)   c                 l    U R                   R                  5         U R                  R                  5         g rH   )rx   rc   r|   rf   s    r'   rc   	Tee.flushC  s"    JJLLr)   )
rx   ry   rz   r|   r{   rv   rw   r"   r}   rQ   )NTF)rk   rl   rm   rn   ro   r[   r   propertyr}   setterr~   r   r   rQ   r^   r   rc   rp   rq   r)   r'   rs   rs      si    " NS:   
==K K*"r)   rs   )r   r   )a)ro   
__future__r   r   r   r   unicoder,   r-   r4   r6   r   rR   r   r   r   r?   r(   r/   r   r   r   objectr   rs   rq   r)   r'   <module>r      sv     S R  	 	 
   =
  ./C(LY0(@26 <y& yr)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              # -*- coding: utf-8 -*-

"""This package contains the following external libraries used in pygimplib:
* `mock`: http://www.voidspace.org.uk/python/mock/
* `future`: https://pypi.python.org/pypi/future

The library modules are treated as system modules, i.e. there is no need to
import them with an absolute or explicit relative path.
"""

from __future__ import absolute_import, division, print_function, unicode_literals
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               Copyright (c) 2013-2016 Python Charmers Pty Ltd, Australia

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  from __future__ import absolute_import
import sys
__future_module__ = True

if sys.version_info[0] < 3:
    from dummy_thread import *
else:
    raise ImportError('This package should not be accessible on Python 3. '
                      'Either you are trying to run from the python-future src folder '
                      'or your installation of python-future is corrupted.')
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        from __future__ import absolute_import
import sys
__future_module__ = True

if sys.version_info[0] < 3:
    from markupbase import *
else:
    raise ImportError('This package should not be accessible on Python 3. '
                      'Either you are trying to run from the python-future src folder '
                      'or your installation of python-future is corrupted.')
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          from __future__ import absolute_import
import sys
__future_module__ = True

if sys.version_info[0] < 3:
    from thread import *
else:
    raise ImportError('This package should not be accessible on Python 3. '
                      'Either you are trying to run from the python-future src folder '
                      'or your installation of python-future is corrupted.')
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              from __future__ import absolute_import
import sys
__future_module__ = True

if sys.version_info[0] < 3:
    from __builtin__ import *
    # Overwrite any old definitions with the equivalent future.builtins ones:
    from future.builtins import *
else:
    raise ImportError('This package should not be accessible on Python 3. '
                      'Either you are trying to run from the python-future src folder '
                      'or your installation of python-future is corrupted.')
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       from __future__ import absolute_import
import sys

if sys.version_info[0] < 3:
    from copy_reg import *
else:
    raise ImportError('This package should not be accessible on Python 3. '
                      'Either you are trying to run from the python-future src folder '
                      'or your installation of python-future is corrupted.')
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      """
future: Easy, safe support for Python 2/3 compatibility
=======================================================

``future`` is the missing compatibility layer between Python 2 and Python
3. It allows you to use a single, clean Python 3.x-compatible codebase to
support both Python 2 and Python 3 with minimal overhead.

It is designed to be used as follows::

    from __future__ import (absolute_import, division,
                            print_function, unicode_literals)
    from builtins import (
             bytes, dict, int, list, object, range, str,
             ascii, chr, hex, input, next, oct, open,
             pow, round, super,
             filter, map, zip)

followed by predominantly standard, idiomatic Python 3 code that then runs
similarly on Python 2.6/2.7 and Python 3.3+.

The imports have no effect on Python 3. On Python 2, they shadow the
corresponding builtins, which normally have different semantics on Python 3
versus 2, to provide their Python 3 semantics.


Standard library reorganization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

``future`` supports the standard library reorganization (PEP 3108) through the
following Py3 interfaces:

    >>> # Top-level packages with Py3 names provided on Py2:
    >>> import html.parser
    >>> import queue
    >>> import tkinter.dialog
    >>> import xmlrpc.client
    >>> # etc.

    >>> # Aliases provided for extensions to existing Py2 module names:
    >>> from future.standard_library import install_aliases
    >>> install_aliases()

    >>> from collections import Counter, OrderedDict   # backported to Py2.6
    >>> from collections import UserDict, UserList, UserString
    >>> import urllib.request
    >>> from itertools import filterfalse, zip_longest
    >>> from subprocess import getoutput, getstatusoutput


Automatic conversion
--------------------

An included script called `futurize
<http://python-future.org/automatic_conversion.html>`_ aids in converting
code (from either Python 2 or Python 3) to code compatible with both
platforms. It is similar to ``python-modernize`` but goes further in
providing Python 3 compatibility through the use of the backported types
and builtin functions in ``future``.


Documentation
-------------

See: http://python-future.org


Credits
-------

:Author:  Ed Schofield
:Sponsor: Python Charmers Pty Ltd, Australia, and Python Charmers Pte
          Ltd, Singapore. http://pythoncharmers.com
:Others:  See docs/credits.rst or http://python-future.org/credits.html


Licensing
---------
Copyright 2013-2016 Python Charmers Pty Ltd, Australia.
The software is distributed under an MIT licence. See LICENSE.txt.

"""

__title__ = 'future'
__author__ = 'Ed Schofield'
__license__ = 'MIT'
__copyright__ = 'Copyright 2013-2016 Python Charmers Pty Ltd'
__ver_major__ = 0
__ver_minor__ = 16
__ver_patch__ = 0
__ver_sub__ = ''
__version__ = "%d.%d.%d%s" % (__ver_major__, __ver_minor__,
                              __ver_patch__, __ver_sub__)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            