
    	]j                         U d Z ddlZddlmZ ddlmZmZ dZee	df   e
d<   defdee	   d	ee	   d
ee	   fdZde	dz  d
e	dz  fdZy)z4
Utility helpers for LocalFiles storage operations.
    N)Path)IterableOptional)mydatazlabel-studio-data.AUTO_ROOT_CANDIDATESbase_dir
candidatesreturnc                     t        | xs t        j                               }|D ]@  }||z  j                         }|j	                         s't        |j                               c S  y)zGReturn the first existing candidate directory relative to ``base_dir``.N)r   osgetcwd
expanduseris_dirstrresolve)r   r	   search_rootcandidate_name	candidates        W/root/env/lib/python3.12/site-packages/label_studio/io_storages/localfiles/functions.pyautodetect_local_files_rootr      s`     x.299;/K$ , >1==?	y((*++,
     raw_pathc                     | y| j                         }|dk(  ry|j                  dt        j                        }t        j                  j                  |      }|S )a  Return a canonical representation for LocalFiles paths.

    We need consistent paths because permission checks compare the requested
    directory with storage.path prefixes. Users often enter trailing slashes or
    Windows separators; normalizing here prevents mismatches.
    N \)stripreplacer   seppathnormpath)r   trimmed	collapsed
normalizeds       r   normalize_storage_pathr$      sQ     nnG"}bff-I!!),Jr   )__doc__r   pathlibr   typingr   r   r   tupler   __annotations__r   r$    r   r   <module>r+      st    
  %(G eCHo G #@T
sm
08
c]
S4Z C$J r   