+
     iG  c                   sZ    R t ^ RIt^ RIt^ RIHtHtHt ^ RIHt ^ RI	H
t
  ! R R4      tR# )zPath constants to be used.N)ListUnionOptional)logger)	UserUtilsc                   s  a  ] tR t^"t o Rt]V 3R lR l4       t]R 4       t]RV 3R lR ll4       t]RR l4       t	]V 3R lR	 l4       t
]R
 4       t]V 3R lR l4       t]RV 3R lR ll4       t]V 3R lR l4       tRtV tR# )	PathUtilsz.config/input-remapper-2c                    < V ^8  d   QhRS[ /#    returnstrZformat__classdict__   "@/usr/lib/python3.14/site-packages/inputremapper/configs/paths.py__annotate__PathUtils.__annotate__&   s     @ @ @    c                 sz    \         P                  P                  \        P                  \
        P                  4      # )N)ospathjoinr   Zhomer   rel_path r   r   config_pathZPathUtils.config_path%   s#    
 ww||INNI,>,>??r   c                s.    \         P                  ! RV \        P                  4       \        P
                  ! V \        P                  \        P                  R7       R#   \         d+    \        P
                  ! T \        P                  R7        R# i ; i)z$Set the owner of a path to the user.zChown "%s", "%s")userZgroup)r   N)r   Zdebugr   r   shutilchownZLookupErrorr      &r   r   ZPathUtils.chown,   sX    	4LL+T9>>BLLINN)..I 	4LLINN33	4s   AA 1BBc                sJ   < V ^8  d   QhRS[ S[S[P                  3,          /# )r   r   )r   r   r   PathLiker   r   r   r   r   7   s"      E#r{{*+ r   c                s   \        V 4      P                  R4      '       d   \        RV  24      h\        P                  P                  V 4      '       d   R# V'       d   \        P                  ! RV 4       \        P                  \        P                  P                  V 4      RR7       \        P                  ! V 4       \        P                  V 4       R# )zBCreate an empty file and all its parent dirs, give it to the user.Z/z'Expected path to not end with a slash: NzCreating file "%s"Flog)r   endswithZ
ValueErrorr   r   existsr   infor   mkdirZdirnameZmknodr   )r   r    s   &&r   touchZPathUtils.touch6   s     t9c""FtfMNN77>>$KK,d3-59
r   c                s|   V R8X  g   V f   R# \         P                  P                  V 4      '       d   R# V'       d   \        P                  ! RV 4       \         P                  P                  V 4      ^ ,          p\        P                  VRR7       \         P                  ! V 4       \        P                  V 4       R# )z%Create a folder, give it to the user.Z NzCreating dir "%s"Fr   )
r   r   r"   r   r#   splitr   r$   Zmakedirsr   )r   r    Zbase   && r   r$   ZPathUtils.mkdirG   s{     2:77>>$KK+T2 ww}}T"1%%(
Dr   c                s`   < V ^8  d   QhRS[ S[P                  S[3,          RS[S[,          /# )r   r   r	   )r   r   r   r   r    r   r   r   r   r   \   s-      bkk3./ DI r   c                s   . p \         P                  P                  V 4      w  rVP                  V4       V \         P                  P                  8X  d   VP                  V 4       MV '       d   Kn   VP                  4        V# )z!Split the path into its segments.)r   r   r&   ZappendZsepZreverse)r   ZpartsZtails   &  r   	split_allZPathUtils.split_all[   sa     t,JDLLrww{{"T"4r   c                s    \         P                  P                  V 4      '       g   R# \         P                  P                  V 4      '       d   \        P
                  ! V 4       R# \         P                  ! V 4       R# )zRemove whatever is at the path.N)r   r   r"   Zisdirr   Zrmtreeremover   r   r   r)   ZPathUtils.removem   sD     ww~~d##77==MM$IIdOr   c                s&   < V ^8  d   QhRS[ RS[ /# )r   
group_namer	   r
   r   r   r   r   r   y   s      C C r   c                sL    R F  pW9   g   K  V P                  VR4      p K  	  V # )zvReplace characters listed in
https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words
with an underscore.
z
/\?%*:|"<>Z_)Zreplace)r*   Z	characters   & r   sanitize_path_componentZ!PathUtils.sanitize_path_componentx   s.     'I&'//	3?
 ' r   Nc                sF   < V ^8  d   QhRS[ S[,          RS[ S[,          /# )r   r*   preset)r   r   r   r   r   r   r      s#     > >HSM >(3- >r   c                sb   \         P                  P                  \        P	                  4       R4      pV f   V# \        P                  V 4      p Ve   VP                  R4      '       g   V R2pVf    \         P                  P                  W 4      # \         P                  P                  W V4      # )z9Get a path to the stored preset, or to store a preset to.Zpresetsz.json)r   r   r   r   r   r+   r!   )r*   r,   Zpresets_baser'   r   get_preset_pathZPathUtils.get_preset_path   s     ww||I$9$9$;YG66zB
 ??7++"85)>77<<99ww||Lf==r   c                r   r   r
   r   r   r   r   r      s     = =3 =r   c                 sj    \         P                  P                  ! \        P	                  4       .V O5!  # )z(Get a path in ~/.config/input-remapper/.)r   r   r   r   r   )Zpathss   *r   get_config_pathZPathUtils.get_config_path   s%     ww||I113<e<<r   r   )T)NN)Z__name__Z
__module__Z__qualname__Z__firstlineno__r   Zstaticmethodr   r   r%   r$   r(   r)   r+   r-   r.   Z__static_attributes__Z__classdictcell__)r   s   @r   r   r   "   s     )H@ @ 4 4      &  "     > > >* = =r   r   )Z__doc__r   r   Ztypingr    r   r   Zinputremapper.logging.loggerr   Zinputremapper.userr   r   r   r   r   <module>r/      s*   , ! 
  ( ( / (z= z=r   