
    yi8                         S r SrSSKrSSKrSSKJrJrJ	r	  S r
SSS.S jrSS.S	 jrS
 rSS.S jr0 \l        S rSSSS.rSSS.S jrS rS rS rSS.S jrSSS.S jrS rS  rS! rg)"zm
This module has a similar scope to os.path, containing utility
functions for dealing with paths in Blender.
)abspathbasename
clean_namedisplay_namedisplay_name_to_filepathdisplay_name_from_filepath
ensure_extextensions_imageextensions_movieextensions_audio	is_subdirmodule_namesnative_pathsepreduce_dirsrelpathresolve_ncase    N)r   r
   r	   c                 B    U R                  US5      R                  5       $ )NF)path_resolveas_bytes)varattrs     P/home/wildlama/Downloads/blender-5.1.2-linux-x64/5.1/scripts/modules/bpy/path.py_getattr_bytesr   '   s    D%(1133    )startlibraryc                   [        U [        5      (       a  U R                  S5      (       a  U(       a2  [        R                  R                  [        [        US5      5      5      n[        R                  R                  Uc7  [        R                  R                  [        [        R                  S5      5      OUU SS 5      $  U $ U R                  S5      (       a  U(       a2  [        R                  R                  [        UR                  5      5      n[        R                  R                  Uc7  [        R                  R                  [        R                  R                  5      OUU SS 5      $ U $ )a  
Returns the absolute path relative to the current blend file
using the "//" prefix.

:param path: The path to convert to absolute.
:type path: str | bytes
:param start: Relative to this path,
   when not set the current filename is used.
:type start: str | bytes | None
:param library: The library this path is from. This is only included for
   convenience, when the library is not None its path replaces *start*.
:type library: :class:`bpy.types.Library` | None
:return: The absolute path.
:rtype: str
   //filepathN   //)
isinstancebytes
startswith_ospathdirnamer   r   join_bpydatar   )r&   r   r   s      r   r   r   +   s     $??5!!((N7J?@B88===   		:!FG&+QR 	 "( K ??4  ((G,,-/88===   !3!34&+QR  Kr   )r   c                   [        U [        5      (       au  U R                  S5      (       d\  Uc7  [        R                  R                  [        [        R                  S5      5      nS[        R                  R                  X5      -   $  U $ U R                  S5      (       d\  Uc7  [        R                  R                  [        R                  R                  5      nS[        R                  R                  X5      -   $ U $ )a  
Returns the path relative to the current blend file using the "//" prefix.

:param path: An absolute path.
:type path: str | bytes
:param start: Relative to this path,
   when not set the current filename is used.
:type start: str | bytes | None
:return: The relative path.
:rtype: str
r   r   r!   )r"   r#   r$   r%   r&   r'   r   r)   r*   r   r   )r&   r   s     r   r   r   S   s     $u%%}((		:)NO388++D888 & K t$$}((););<#((**4777Kr   c                 "   SSK JnJnJn  U" U" U 5      5      n U" U" U5      5      n[	        U 5      [	        U5      :  aQ  [        U[        5      (       a  UR                  S5      OUnU R                  UR                  U5      U-   5      (       a  gg)a)  
Returns true if *path* is in a subdirectory of *directory*.
Both paths must be absolute.

:param path: An absolute path.
:type path: str | bytes
:param directory: The parent directory to check against.
:type directory: str | bytes
:return: Whether or not the path is a subdirectory.
:rtype: bool
r   )normpathnormcasesepasciiTF)
os.pathr-   r.   r/   lenr"   r#   encoder$   rstrip)r&   	directoryr-   r.   r/   s        r   r   r   m   sx     0/HTN#D),-I
4y3y>!%/	5%A%Acjj!s??9++C03677r   _)replacec                   ^ TS:w  a)  [        T5      S:w  d  [        T5      S:  a  [        S5      eU4S jnU" 5       nU R                  U5      $ )a  
Returns a name with characters replaced that
may cause problems under various circumstances,
such as writing to a file.

All characters besides A-Z/a-z, 0-9 are replaced with "_"
or the *replace* argument if defined.

:param name: The path name.
:type name: str | bytes
:param replace: The replacement for non-valid characters.
:type replace: str
:return: The cleaned name.
:rtype: str
r6         z&Value must be a single ascii characterc                     > [         R                  n U R                  T5      nUc,  Sn[        R	                  U Vs0 s H  o3T_M     sn5      nXT'   U$ s  snf )N)r   r9   r                      	   
                                                                      !   "   #   $   %   &   '   (   )   *   +   ,   .   /   :   ;   <   =   >   ?   @   [   \   ]   ^   `   {   |   }   ~                                                                                                                                                                                                                                                                                                                                                                                                   )r   _trans_cachegetstr	maketrans)trans_cachetrans	bad_charscharr7   s       r   maketrans_init"clean_name.<locals>.maketrans_init   s\     --(=I4 MMY"GYT=Y"GHE#(  #Hs   A)r2   ord
ValueError	translate)namer7   r   r   s    `  r   r   r      sN    " #~w<1Gs 2EFF D E>>%  r   c                     [        U 5      [        L a  U R                  SS5      $ U R                  SS5      R                  S5      $ )Nutf8r7   )typer#   decoder3   r  s    r   _clean_utf8r     s;    DzU{{69--{{69-44V<<r   _colon__plus__slash_):+/T)has_ext
title_casec                   U(       a+  [         R                  R                  [        U 5      5      S   n [        R                  5        H  u  p4U R                  XC5      n M     U R                  SS5      R                  S5      n U(       a3  U R                  5       (       a  U R                  5       R                  5       n [        U 5      n U $ )a  
Creates a display string from name to be used in menus and the user interface.
Intended for use with filenames and module names.

:param name: The name to be used for displaying the user interface.
:type name: str
:param has_ext: Remove file extension from name.
:type has_ext: bool
:param title_case: Convert lowercase names to title case.
:type title_case: bool
:return: The display string.
:rtype: str
r   r6    )r%   r&   splitextr   _display_name_literalsitemsr7   lstripislowerlowertitler  )r  r  r  
disp_value
file_values        r   r   r      s     xx  $03 #9">">"@
||J3 #A
 <<S!((-Ddllnnzz|!!#tDKr   c                 b    [         R                  5        H  u  pU R                  X5      n M     U $ )z
Performs the reverse of display_name using literal versions of characters
which aren't supported in a filepath.

:param name: The display name to convert.
:type name: str
:return: The file path.
:rtype: str
)r  r  r7   )r  r  r  s      r   r   r      s.     #9">">"@
||J3 #AKr   c                 r    [         R                  R                  [        U 5      5      S   n [	        U 5      n U $ )z
Returns the path stripped of directory and extension,
ensured to be UTF-8 compatible.

:param name: The file path to convert.
:type name: str
:return: The display name.
:rtype: str
r   )r%   r&   r  r   r  r
  s    r   r   r      s0     88Xd^,Q/DtDKr   c                 :   ^ U4S jmT" U 5      u  pU(       a  U$ U $ )z
Resolve a case insensitive path on a case sensitive system,
returning a string with the path if found else return the original path.

:param path: The path name to resolve.
:type path: str
:return: The resolved path.
:rtype: str
c                   > U (       a$  [         R                  R                  U 5      (       a  U S4$ [         R                  R                  U 5      n[         R                  R	                  U 5      nU S S nU(       dp  [        U5      [        U 5      :  a  U S [        U 5      [        U5      -
   n[         R                  R                  U5      n[         R                  R	                  U5      n[         R                  R                  U5      (       d  X :X  a  U S4$ T	" U5      u  p$U(       d  U S4$ [         R                  R                  U5      (       a   [         R                  " U5      nOU S4$ UR                  5       nS nU H  nUR                  5       U:X  d  M  Un  O   U(       a$  [         R                  R                  X'5      U-   S4$ U S4$ ! [         a    U S4s $ f = f)NTr   F)r%   r&   existsr   r'   r2   isdirlistdirPermissionErrorr  r(   )
r&   filenamedirpathsuffixfoundfilesfilename_lowf_iter_nocasef_iter_ncase_path_founds
            r   r/  (resolve_ncase.<locals>._ncase_path_found  s   sxxt,,: 88$$T*((""4(bq7|c$i'7s4y3w<78xx((1Hhh&&w/Gxxw''U{".w7NGU{"
 88>>'""#G,
 ;~~'F||~- & 
 88==86A4GG ;% # #U{"#s   G G G  )r&   
ncase_pathr*  r/  s      @r   r   r     s%    1f *$/J:(D(r   F)case_sensitivec                    U(       a  U R                  U5      (       a  U $  X-   $ U [        U5      * S R                  5       R                  UR                  5       5      (       a  U $ X-   $ )a  
Return the path with the extension added if it is not already set.

:param filepath: The file path.
:type filepath: str
:param ext: The extension to check for, can be a compound extension. Should
          start with a dot, such as ``.blend`` or ``.tar.gz``.
:type ext: str
:param case_sensitive: Check for matching case when comparing extensions.
:type case_sensitive: bool
:return: The file path with the given extension.
:rtype: str
N)endswithr2   r  )r   extr3  s      r   r   r   Q  sh     S!!O " > SXIJ%%'00==O>r    )	recursivepackagec                8   SSK JnJn  / nU(       a  US-   OSn[        [        R
                  " U 5      5       H  nUS:X  a	  U(       d  M  UR                  S5      (       a(  US:w  a"  U" X5      nUR                  XgSS -   U45        MP  UR                  S5      (       a  Mh  U" X5      n	U" U	S5      nU" U5      (       d  M  UR                  Xg-   U45        U(       d  M  [        U	S	S
9 H*  u  pUR                  SR                  Xg-   U
5      U45        M,     M     U$ )a  
Return a list of modules which can be imported from *path*.

:param path: a directory to scan.
:type path: str
:param recursive: Also return submodule names for packages.
:type recursive: bool
:param package: Optional string, used as the prefix for module names (without the trailing ".").
:type package: str
:return: a list of string pairs (module_name, module_file).
:rtype: list[tuple[str, str]]
r   )r(   isfile.r7  modulesz.pyz__init__.pyT)r8  z	{:s}.{:s})r1   r(   r;  sortedr%   r%  r5  appendr$   r   format)r&   r8  r9  r(   r;  r=  package_prefixr'  fullpathr5   mod_namemod_paths               r   r   r   j  s	    %G(/gmRN3;;t,-	!Nu%%(m*CD+HNNNa^;XFG$$S))T,II}5Hh 98DE9.:9PT.U*'..~/H(S$(  /V .& Nr   c                 d    [         R                  R                  U SS S;   a	  U SS 5      $ U 5      $ )z
Equivalent to ``os.path.basename``, but skips a "//" prefix.

Use for Windows compatibility.

:param path: The path to get the base name of.
:type path: str | bytes
:return: The base name of the given path.
:rtype: str
Nr    >   r   r!   )r%   r&   r   r&   s    r   r   r     s4     88bq])BT!"XMMMMr   c                    [        U 5      [        L af  [        R                  S:X  a  U R	                  SS5      $ U R                  S5      (       a  SU SS R	                  SS5      -   $ U R	                  SS5      $ [        R                  S:X  a  U R	                  SS5      $ U R                  S5      (       a  SU SS R	                  SS5      -   $ U R	                  SS5      $ )	z
Replace the path separator with the system's native ``os.sep``.

:param path: The path to replace.
:type path: str
:return: The path with system native separators.
:rtype: str
r  \r!   r    N   \   /r   )r  r   r%   r/   r7   r$   rG  s    r   r   r     s     DzS77c><<c**t$$d12h..sD999||C..77c><<t,,u%%tABx//e<<<||D%00r   c           
         [        U  Vs1 s H?  n[        R                  R                  [        R                  R	                  U5      5      iMA     sn5      n U R                  S S9  [        [        U 5      S-
  SS5       HN  n[        U5       H<  n[        X   5      [        X   5      :X  a    M0  [        X   X   5      (       d  M9  X	   ML     MP     U $ s  snf )a	  
Given a sequence of directories, remove duplicates and
any directories nested in one of the other paths.
(Useful for recursive path searching).

:param dirs: Sequence of directory paths.
:type dirs: Sequence[str]
:return: A unique list of paths.
:rtype: list[str]
c                     [        U 5      $ )N)r2   )ds    r   <lambda>reduce_dirs.<locals>.<lambda>  s    CFr   )keyr9   )	listr%   r&   r-   r   sortranger2   r   )dirsrN  ijs       r   r   r     s     FA""388#3#3A#67FGDII"I#3t9q="b)qA47|s47|+47DG,,G  * K Gs   AC)__doc____all__bpyr)   osr%   	_bpy_pathr   r
   r	   r   r   r   r   r   r   r  r  r   r   r   r   r   r   r   r   r   r1  r   r   <module>r^     s   

&   4   %P   4, !$ 8!v 
 = 
		  #'4 B ?)D 16 2 %*2 'TN16r   