
    d:                     b    d Z ddlZddlZddlZddlZg dZi Zd Zd
dZd
dZ	d
dZ
d
dZd	 ZdS )zCache lines from Python source files.

This is intended to read lines from modules imported -- hence if a filename
is not found, it will look down the module search path for a file by
that name.
    N)getline
clearcache
checkcache	lazycachec                  8    t                                            dS )zClear the cache entirely.N)cacheclear       /croot/python-split_1694437901252/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_plac/lib/python3.11/linecache.pyr   r      s    	KKMMMMMr   c                 v    t          | |          }d|cxk    rt          |          k    rn n||dz
           S dS )z~Get a line for a Python source file from the cache.
    Update the cache if it doesn't contain an entry for this file already.    )getlineslen)filenamelinenomodule_globalsliness       r   r   r      sO     X~..EF    c%jj     VaZ  2r   c                     | t           v r3t           |          }t          |          dk    rt           |          d         S 	 t          | |          S # t          $ r t	                       g cY S w xY w)zGet the lines for a Python source file from the cache.
    Update the cache if it doesn't contain an entry for this file already.r      )r   r   updatecacheMemoryErrorr   )r   r   entrys      r   r   r   $   sx     5hu::???1%%8^444   			s   A A+*A+c                    | 't          t                                                    }n| t          v r| g}ndS |D ]} t          |          }t          |          dk    r#|\  }}}}|-	 t	          j        |          }n+# t          $ r t                              | d           Y jw xY w||j        k    s||j	        k    rt                              | d           dS )zUDiscard cache entries that are out of date.
    (This is not checked upon each call!)Nr   )
listr   keysr   osstatOSErrorpopst_sizest_mtime)r   	filenamesr   sizemtimer   fullnamer   s           r   r   r   4   s     &&			U		J		 & &hu::??',$eUH=	78$$DD 	 	 	IIh%%%H	 4<5DM#9#9IIh%%%& &s   )A>>%B&%B&c                    | t           v r9t          t           |                    dk    rt                               | d           | r*|                     d          r|                     d          rg S | }	 t          j        |          }n<# t          $ r. | }t          | |          r	 t          |          d                     }|g cY S t          |          dd |	                                D             |ft           | <   t           |          d         cY S # t          t          f$ r Y nw xY wt
          j                            |           rg cY S t          j        D ]a}	 t
          j                            ||          }n# t          t           f$ r Y 7w xY w	 t          j        |          } n# t          $ r Y ^w xY wg cY S Y nw xY w	 t#          j        |          5 }|                                }ddd           n# 1 swxY w Y   n# t          t(          t*          f$ r g cY S w xY w|r+|d                             d	          s|dxx         d	z  cc<   |j        |j        }
}	|	|
||ft           | <   |S )
zUpdate a cache entry and return its list of lines.
    If something's wrong, print a message, discard the cache entry,
    and return an empty list.r   N<>r   c                     g | ]}|d z   S )
r
   ).0lines     r   
<listcomp>zupdatecache.<locals>.<listcomp>p   s    ???TTD[???r   r   r,   )r   r   r!   
startswithendswithr   r   r    r   
splitlinesImportErrorpathisabssysjoin	TypeErrorAttributeErrortokenizeopen	readlinesUnicodeDecodeErrorSyntaxErrorr"   r#   )r   r   r'   r   basenamedatadirnamefpr   r%   r&   s              r   r   r   P   s   
 5uX1$$IIh%%% ++C00 X5F5Fs5K5K 	H*wx   ( ( ( X~.. 	**Xq)++ < IIIII??T__->->???	#h Xq))))  )   " 7=="" 	IIIx 	 	G7<<::~.   wx((    III	 I(R]8$$ 	#LLNNE	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	#'5   			 U2Y''-- b			T			,%DE5(2E(OLs   4B
 
G(DGA
GD(%G'D(($GG E>=G>FGFGF,*G,
F96G8F99GGH G<0H <H  H H H H$#H$c                    | t           v r"t          t           |                    dk    rdS dS | r*|                     d          r|                     d          rdS |rd|v r|d         }|                    d          x}0|                    d	          x}r	 |j        }n# t          $ r Y nw xY wt          |d
d          }|r$|r"t          j	        ||          }|ft           | <   dS dS )a  Seed the cache for filename with module_globals.

    The module loader will be asked for the source only when getlines is
    called, not immediately.

    If there is an entry in the cache already, it is not altered.

    :return: True if a lazy load is registered in the cache,
        otherwise False. To register such a load a module loader with a
        get_source method must be found, the filename must be a cacheable
        filename, and the filename must not be already cached.
    r   TFr)   r*   __name__
__loader__N__spec__
get_source)
r   r   r1   r2   getloaderr:   getattr	functoolspartial)r   r   namerJ   specrH   	get_liness          r   r   r      s,    5uX1$$45 ++C00 X5F5Fs5K5K u *66j)$((666F?%))*555t ![FF%   DV\488
 	J 	!)*d;;I(lE(O45s   B 
B,+B,)N)__doc__rL   r7   r   r;   __all__r   r   r   r   r   r   r   r
   r   r   <module>rS      s         



 				 
>
>
>
 	  
       & & & &8@ @ @ @F# # # # #r   