o
    K+g:                     @   sl   d Z ddlZddlZddlZddlZg dZi Zdd ZdddZddd	Z	dd
dZ
dddZd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                   C   s   t   dS )zClear the cache entirely.N)cacheclear r   r   ;/var/www/html/squashfs-root/usr/lib/python3.10/linecache.pyr      s   r   c                 C   s8   t | |}d|  krt|krn dS ||d  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linesr   r   r	   r      s
   
r   c                 C   sR   | t v rt |  }t|dkrt |  d S zt| |W S  ty(   t  g  Y S 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   entryr   r   r	   r   $   s   r   c              	   C   s   | du rt t }n
| tv r| g}ndS |D ]?} t|  }t|dkr$q|\}}}}|du r/qzt|}W n tyE   t| d Y qw ||jksP||j	krVt| d q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   Z	filenamesr   sizemtimer   fullnamer   r   r   r	   r   4   s,   r   c                 C   s  | t v rtt |  dkrt | d | r| dr | dr g S | }zt|}W n ty   | }t| |rmz	t |  d  }W n t	tfyK   Y n"w |du rTg  Y S t|ddd |
 D |ft | < t |  d  Y S tj| rwg  Y S tjD ](}z	tj||}W n ttfy   Y qzw zt|}W  n ty   Y qzw g  Y S Y nw zt|}| }W d   n1 sw   Y  W n tttfy   g  Y S w |r|d	 d
s|d	  d
7  < |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                 S   s   g | ]}|d  qS )
r   ).0liner   r   r	   
<listcomp>p   s    zupdatecache.<locals>.<listcomp>r   r#   )r   r   r   
startswithendswithr   r   r   r   ImportError
splitlinespathisabssysjoin	TypeErrorAttributeErrortokenizeopen	readlinesUnicodeDecodeErrorSyntaxErrorr   r   )r   r   r    r   basenamedatadirnamefpr   r   r   r   r   r	   r   P   sl   


)
r   c                 C   s   | t v rtt |  dkrdS dS | r| dr| drdS |r^d|v r^|d }|d }du rG|d	 }rGz|j}W n	 tyF   Y nw t|d
d}|r^|r^t	||}|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   r(   r)   getloaderr1   getattr	functoolsZpartial)r   r   namer@   specr>   Z	get_linesr   r   r	   r      s*   

r   )N)__doc__rB   r.   r   r2   __all__r   r   r   r   r   r   r   r   r   r   r	   <module>   s    




C