
    k7i*                         S SK r S SKJrJr  S SKJr  S SKJr  S SKJ	r	J
r
  SS\-  \\   -  S\\S4   4S	 jr\	" S
S9 " S S5      5       rg)    N)IterableSequence)Any)field)frozento_tuple_convertervaluereturn.c                 8    [        S [        U 5       5       5      $ )Nc              3   ^   #    U  H#  oR                  5       R                  S 5      v   M%     g7f).N)lowerlstrip).0es     S/home/james-whalen/.local/lib/python3.13/site-packages/cyclopts/validators/_path.py	<genexpr> ext_converter.<locals>.<genexpr>   s$     J0I1!!#&&0Is   +-)tupler   )r	   s    r   ext_converterr   
   s    J0B50IJJJ    T)kw_onlyc                       \ rS rSr% SrSr\\S'    Sr\\S'    Sr	\\S'    \
" S\S	9r\\\   -  \S
'    S rS\S\4S jrSrg)Path   u  Assertions on properties of :class:`pathlib.Path`.

Example Usage:

.. code-block:: python

    from cyclopts import App, Parameter, validators
    from pathlib import Path
    from typing import Annotated

    app = App()


    @app.default
    def main(
        # ``src`` must be a file that exists.
        src: Annotated[Path, Parameter(validator=validators.Path(exists=True, dir_okay=False))],
        # ``dst`` must be a path that does **not** exist.
        dst: Annotated[Path, Parameter(validator=validators.Path(dir_okay=False, file_okay=False))],
    ):
        "Copies src->dst."
        dst.write_bytes(src.read_bytes())


    app()

.. code-block:: console

    $ my-script foo.bin bar.bin  # if foo.bin does not exist
    ╭─ Error ───────────────────────────────────────────────────────╮
    │ Invalid value "foo.bin" for "SRC". "foo.bin" does not exist.  │
    ╰───────────────────────────────────────────────────────────────╯

    $ my-script foo.bin bar.bin  # if bar.bin exists
    ╭─ Error ───────────────────────────────────────────────────────╮
    │ Invalid value "bar.bin" for "DST". "bar.bin" already exists.  │
    ╰───────────────────────────────────────────────────────────────╯
FexistsT	file_okaydir_okayN)default	converterextc                     U R                   (       a/  U R                  (       d  U R                  (       d  [        S5      eg g g )NzK(exists=True, file_okay=False, dir_okay=False) is an invalid configuration.)r   r   r   
ValueError)selfs    r   __attrs_post_init__Path.__attrs_post_init__W   s+    ;;t~~dmmjkk 7D~;r   type_pathc                    [        U[        5      (       a-  [        U[        5      (       a  [        eU H  nU " X5        M     g [        U[        R
                  5      (       d  g U R                  (       a  UR                  R                  5       R                  S5      U R                  ;  ar  [        U R                  5      S:X  a  [        SU SU R                  S    S35      eSSR                  S	 U R                   5       5      -   S
-   n[        SU SU S35      eUR                  5       (       a  U R                  (       dD  UR                  5       (       a/  U R                   (       a  [        SU S35      e[        SU S35      eU R                   (       dE  UR#                  5       (       a/  U R                  (       a  [        SU S35      e[        SU S35      eg g U R                  (       a  [        SU S35      eg )Nr      "z" must have extension "r   z".{z, c              3   .   #    U  H  nS U S 3v   M     g7f)r+   N )r   xs     r   r    Path.__call__.<locals>.<genexpr>j   s     0L8a1QCq8s   }z-" does not match one of supported extensions z Only directory is allowed, but "z" is a file.z" already exists.zOnly file is allowed, but "z" is a directory.z" does not exist.)
isinstancer   str	TypeErrorpathlibr   r!   suffixr   r   lenr#   joinr   r   is_filer   is_dir)r$   r'   r(   p
pretty_exts        r   __call__Path.__call__[   s   dH%%$$$U  dGLL11xxDKK--/66s;488Ktxx=A%$q.Edhhqk]RT%UVV!$tyy0L4880L'L!Ls!RJ$q.[\f[ggh%ijj{{}}~~$,,..}}(+KD6Q])^__(1TF2C)DEE}}~~(+FtfL])^__(1TF2C)DEE	 *7}
  1TF*;!<== r   r.   )__name__
__module____qualname____firstlineno____doc__r   bool__annotations__r   r   r   r   r!   r3   r   r%   r   r=   __static_attributes__r.   r   r   r   r      sq    %N FDRIt Hd  %T]KCx}	K
l>c > >r   r   )r5   collections.abcr   r   typingr   attrsr   cyclopts.utilsr   r   r   r3   r   r   r.   r   r   <module>rK      s`     .   5Khsm3 Kc3h K k> k> k>r   