
    l:i                     r    d dl mZ d dlZd dlmZ d dlmZmZmZ d dl	m
Z
 g dZed        Zd Zd	 Zd
 ZdZy)    )CounterN)Path)!get_valid_history_without_currentmemoizereplace_argument)shell)z no such file or directory: (.*)$z/cannot access '(.*)': No such file or directoryz!: (.*): No such file or directoryzcan't cd to (.*)$c                     t         D ]=  }t        j                  || j                        }|s&|d   | j                  v s8|d   c S  y )Nr   )patternsrefindalloutputscript_parts)commandpatternfounds      V/var/www/html/bot/venv/lib/python3.12/site-packages/thefuck/rules/path_from_history.py_get_destinationr      sC      

7GNN3Qx7///Qx	     c                 *    t        t        |             S N)boolr   )r   s    r   matchr      s     )**r   c                 0   t               }t        |       D ]g  }t        j                  |      }|dd  D ]H  }|j	                  d      s|j	                  d      s&|j                  d      r|d d }||xx   dz  cc<   J i d |j                  d       D        S )N   /~c              3   &   K   | ]	  \  }}|  y wr    ).0path_s      r   	<genexpr>z7_get_all_absolute_paths_from_history.<locals>.<genexpr>)   s     :WT1D:s   )r   r   r   split_command
startswithendswithmost_common)r   counterlinesplittedparams        r   $_get_all_absolute_paths_from_historyr,      s    iG1': $&&t,ab\ 	$E$(8(8(=>>#&!#2JE!#	$$ ; 3 3D 9::r   c                     t        |       }t        |       }|D cg c]Q  }|j                  |      r>t        |      j	                         j                         rt        | j                  ||      S c}S c c}w r   )r   r,   r&   r   
expanduserexistsr   script)r   destinationpathsr!   s       r   get_new_commandr3   ,   si    "7+K09E 2{!;T
%%'..0 W^^[$? 2 2 2s   AA4i   )collectionsr   r   thefuck.systemr   thefuck.utilsr   r   r   thefuck.shellsr   r
   r   r   r,   r3   priorityr   r   r   <module>r9      sL     	 6 6  " 	  	 +; 2 r   