ó
âdc           @` s-  d  Z  d d l m Z m Z m Z m Z d d l Td d l Z d d l	 Z	 d d l
 Z
 d d l Z d d l m Z d d d	 d
 d d g Z d „  Z d e f d „  ƒ  YZ d e j j e	 j e ƒ f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   u>   Validation of file paths, directory paths and file extensions.i    (   t   absolute_importt   divisiont   print_functiont   unicode_literals(   t   *Ni   (   t
   _path_dirsu   FileValidatorErrorStatusesu   StringValidatoru   FilenameValidatoru   FilepathValidatoru   DirpathValidatoru   FileExtensionValidatorc         C` s   |  S(   N(    (   t   str_(    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyt   N_   s    t   FileValidatorErrorStatusesc           B` s3   e  Z e e d  ƒ ƒ Z \ Z Z Z Z Z	 Z
 Z RS(   i   (   t   __name__t
   __module__t   listt   ranget   ERROR_STATUSESt   IS_EMPTYt   HAS_INVALID_CHARSt   DRIVE_HAS_INVALID_CHARSt   HAS_TRAILING_SPACESt   HAS_TRAILING_PERIODt   HAS_INVALID_NAMESt   EXISTS_BUT_IS_NOT_DIR(    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR      s   
t   StringValidatorc           B` sA   e  Z d  Z i  Z e d „  ƒ Z e d „  ƒ Z e d „  ƒ Z RS(   uÒ   
  This class is an interface to validate strings.
  
  This class does not specify what strings are valid (whether they contain
  invalid characters, substrings, etc.). This should be handled by subclasses.
  c         C` s   d S(   ug  
    Check if the specified string is valid.
    
    Returns:
      
      * `is_valid` - `True` if the string is valid, `False` otherwise.
      
      * `status_messages` - If the string is invalid, `status_messages` is
        a list of (status code, status message) tuples describing why the string
        is invalid. Otherwise it is an empty list.
    N(    (   t   clst   string_to_check(    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyt   is_valid4   s    c         C` s   d S(   u7   
    Modify the specified string to make it valid.
    N(    (   R   t   string_to_validate(    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyt   validateC   s    c         C` s   | t  |  j | ƒ f S(   N(   t   _t   ERROR_STATUSES_MESSAGES(   R   t   status(    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyt   _get_statusJ   s    (   R	   R
   t   __doc__R   t   classmethodR   R   R   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   *   s
   t   FilenameValidatorc           B` sÐ   e  Z d  Z d Z d d d d d d d d	 d
 d d d d d d d d d d d d d h Z i e d ƒ e j 6e d ƒ e j 6e d ƒ e j	 6e d ƒ e j
 6e d ƒ e j 6Z e d „  ƒ Z e d „  ƒ Z RS(   uS  
  This class is used to validate filenames (i.e. basenames).
  
  In this class, filenames are considered valid if they:
    
    * do not contain control characters with ordinal numbers 0-31 and 127-159
    
    * do not contain the following special characters:
      
        <>:"/\|?*
    
    * do not start or end with spaces
    
    * do not end with one or more periods
    
    * do not have invalid names according to the naming conventions for the
      Windows platform:
      
      http://msdn.microsoft.com/en-us/library/aa365247%28VS.85%29
    
    * are not empty or `None`
  u   [\x00-\x1f\x7f-\x9f<>:"\\/|?*]u   CONu   PRNu   AUXu   NULu   COM1u   COM2u   COM3u   COM4u   COM5u   COM6u   COM7u   COM8u   COM9u   LPT1u   LPT2u   LPT3u   LPT4u   LPT5u   LPT6u   LPT7u   LPT8u   LPT9u   Filename is not specified.u%   Filename contains invalid characters.u    Filename cannot end with spaces.u"   Filename cannot end with a period.u:   "{}" is a reserved name that cannot be used in filenames.
c         C` s  | s | d k r, t |  j t j ƒ g f Sg  } t j |  j | ƒ rc | j |  j t j	 ƒ ƒ n  | j
 d ƒ rŽ | j |  j t j ƒ ƒ n  | j
 d ƒ r¹ | j |  j t j ƒ ƒ n  t j j | ƒ \ } } | j ƒ  |  j k r| j |  j t j ƒ ƒ n  | } | | f S(   u‰   
    Check whether the specified filename is valid.
    
    See the class description for details about when the filename is valid.
    u    u   .N(   t   Nonet   FalseR   R   R   t   ret   searcht   _INVALID_CHARS_PATTERNt   appendR   t   endswithR   R   t   ost   patht   splitextt   uppert   _INVALID_NAMESR   (   R   t   filenamet   status_messagest   roott   unused_R   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   |   s$    c         C` s   t  j |  j d | ƒ j d ƒ j d ƒ } t j j | ƒ \ } } | j ƒ  |  j	 k rh | d | } n  | s} t
 d ƒ } n  | S(   u7  
    Validate the specified filename by removing invalid characters.
    
    If the filename is one of the reserved names for the Windows platform,
    append `' (1)'` to the filename (before the file extension if it has one).
    
    If the filename is truncated to an empty string, return `'Untitled'`.
    u    u    u   .u    (1)u   Untitled(   R$   t   subR&   t   stript   rstripR)   R*   R+   R,   R-   R   (   R   R.   R0   t   ext(    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   œ   s    
*(   R	   R
   R   R&   R-   R   R   R   R   R   R   R   R   R    R   R   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR!   O   s"    t   FilepathValidatorc           B` sÇ   e  Z d  Z d Z d Z d e d Z d e e d Z e j Z i e	 d ƒ e
 j 6e	 d ƒ e
 j 6e	 d ƒ e
 j 6e	 d ƒ e
 j 6e	 d	 ƒ e
 j 6e	 d
 ƒ e
 j 6Z e d „  ƒ Z e d „  ƒ Z RS(   u‡  
  This class is used to validate file paths (relative or absolute).
  
  The same validation rules that apply to filenames in the `FilenameValidator`
  class apply to file paths in this class, with the following exceptions:
    
    * `/` and `\` characters are allowed
    
    * `:` character is allowed to appear at the root level only (as a part of a
      drive letter, e.g. `'C:'`)
  u   \x00-\x1f\x7f-\x9f<>"|?*u   :u   [u   ]u   File path is not specified.u)   Drive letter contains invalid characters.u&   File path contains invalid characters.u8   Path components in the file path cannot end with spaces.u:   Path components in the file path cannot end with a period.u;   "{}" is a reserved name that cannot be used in file paths.
c         C` sW  | s | d  k r, t |  j t j ƒ g f Sg  } t ƒ  } d } t j j | ƒ } t j j	 | ƒ \ } } | r¥ t
 j |  j | ƒ r¥ | j |  j t j ƒ ƒ q¥ n  t j | ƒ } x× | D]Ï } t
 j |  j | ƒ ré | j t j ƒ n  | j d ƒ r| j t j ƒ n  | j d ƒ r-| j t j ƒ n  t j j | ƒ \ }	 }
 |	 j ƒ  |  j k r» | j t j ƒ | |  j t j j |	 ƒ 7} q» q» Wt j | k r¹| j |  j t j ƒ ƒ n  t j | k rä| j |  j t j ƒ ƒ n  t j | k r| j |  j t j ƒ ƒ n  t j | k rF| j d ƒ } | j t j | f ƒ n  | } | | f S(   Nu    u    u   .u   
(   R"   R#   R   R   R   t   setR)   R*   t   normpatht
   splitdriveR$   R%   t$   _INVALID_CHARS_PATTERN_WITHOUT_DRIVER'   R   R   t
   split_pathR&   t   addR   R(   R   R   R+   R,   R-   R   R   t   formatR4   (   R   t   filepathR/   t   statusest   invalid_names_status_messaget   driveR*   t   path_componentst   path_componentR0   R1   R   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   Ö   sP    	c   	      C` s  t  j j | ƒ } t  j j | ƒ \ } } | rK t j |  j d | ƒ } n  t j | ƒ } x– t	 t
 | ƒ ƒ D]‚ } t j |  j d | | ƒ } | j d ƒ j d ƒ } t  j j | ƒ \ } } | j ƒ  |  j k rå | d | } n  | | | <qm Wt  j j t  j j | | Œ ƒ } | S(   Nu    u    u   .u    (1)(   R)   R*   R8   R9   R$   R2   R:   R   R;   R   t   lenR&   R3   R4   R+   R,   R-   t   join(	   R   R>   RA   R*   RB   t   iRC   R0   R5   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   	  s    !(   R	   R
   R   t   _INVALID_CHARSt   _VALID_DRIVE_CHARSR:   R&   R!   R-   R   R   R   R   R   R   R   R   R   R    R   R   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR6   ´   s(   	3t   DirpathValidatorc           B` s“   e  Z d  Z i e d ƒ e j 6e d ƒ e j 6e d ƒ e j 6e d ƒ e j 6e d ƒ e j	 6e d ƒ e j
 6e d ƒ e j 6Z e d „  ƒ Z RS(	   u"  
  This class is used to validate directory paths (relative or absolute).
  
  The same validation rules that apply to file paths in the `FilepathValidator`
  class apply to directory paths in this class, with the following additions:
  
    * the specified path must be a directory path
  u    Directory path is not specified.u)   Drive letter contains invalid characters.u+   Directory path contains invalid characters.u=   Path components in the directory path cannot end with spaces.u?   Path components in the directory path cannot end with a period.u@   "{}" is a reserved name that cannot be used in directory paths.
u'   Specified path is not a directory path.c         C` sj   t  ƒ  j | ƒ \ } } t j j | ƒ rY t j j | ƒ rY | j |  j t j	 ƒ ƒ n  | } | | f S(   N(
   t   superR   R)   R*   t   existst   isdirR'   R   R   R   (   R   t   dirpathR1   R/   R   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   <  s    %(   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R    R   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyRI   #  s    t   FileExtensionValidatorc           B` s{   e  Z d  Z e j Z i e d ƒ e j 6e d ƒ e j 6e d ƒ e j	 6e d ƒ e j
 6Z e d „  ƒ Z e d „  ƒ Z RS(   uL  
  This class is used to validate file extensions.
  
  In this class, file extensions are considered valid if they:
    
    * do not contain control characters with ordinal numbers 0-31 and 127-159
    
    * do not contain the following special characters:
      
        <>:"/\|?*
    
    * do not end with spaces or periods
  u    File extension is not specified.u+   File extension contains invalid characters.u&   File extension cannot end with spaces.u(   File extension cannot end with a period.c         C` sÊ   | s | d  k r, t |  j t j ƒ g f Sg  } t j |  j | ƒ rc | j |  j t j	 ƒ ƒ n  | j
 d ƒ rŽ | j |  j t j ƒ ƒ n  | j
 d ƒ r¹ | j |  j t j ƒ ƒ n  | } | | f S(   Nu    u   .(   R"   R#   R   R   R   R$   R%   R&   R'   R   R(   R   R   (   R   t   file_extensionR/   R   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   c  s    c         C` s(   t  j |  j d | ƒ j d ƒ j d ƒ S(   Nu    u    u   .(   R$   R2   R&   R4   (   R   RO   (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyR   y  s    (   R	   R
   R   R!   R&   R   R   R   R   R   R   R   R    R   R   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyRN   H  s   	(   R   t
   __future__R    R   R   R   t   future.builtinst   future.utilst   futuret   abcR)   R$   t    R   t   __all__R   t   objectR   t   utilst   with_metaclasst   ABCMetaR   R!   R6   RI   RN   (    (    (    sQ   /home/josie/.config/GIMP/2.10/plug-ins/export_layers/pygimplib/path/validators.pyt   <module>   s(   "
		(%eo%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          # -*- coding: utf-8 -*-

"""API for plug-in settings."""

from __future__ import absolute_import, division, print_function, unicode_literals
from future.builtins import *

from .group import *
from .pdbparams import *
from .persistor import *
from .presenter import *
from .presenters_gtk import *
from .settings import *
from .sources import *
from .utils import *

from ._sources_errors import *
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 