o
    g                     @   s   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dlm	Z	 G dd de
Zde
d	ed
edefddZd	ededefddZdd Zdd Ze jdd ZdS )    N)datetime)Path)PYLINT_HOME)get_python_pathc                   @   s   e Zd ZdZdS )ArgumentPreprocessingErrorz8Raised if an error occurs during argument preprocessing.N)__name__
__module____qualname____doc__ r   r   O/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/lint/utils.pyr      s    r   exfilepathcrash_file_pathreturnc                 C   s   t tt t|  }t|dd}| }W d    n1 s$w   Y  d}|	 s1d}|d|  d| d| j
j d7 }z,t|d	dd}|| tj|d
 |d W d    W |S 1 sfw   Y  W |S  ty   td| d Y |S w )Nutf8)encoding zFirst, please verify that the bug is not already filled:
https://github.com/PyCQA/pylint/issues/

Then create a new crash issue:
https://github.com/PyCQA/pylint/issues/new?assignees=&labels=crash%2Cneeds+triage&template=BUG-REPORT.yml

z
Issue title:
Crash ``z`` (if possible, be more specific about what made pylint crash)
Content:
When parsing the following file:

<!--
 If sharing the code is not an option, please state so,
 but providing only the stacktrace would still be helpful.
 -->

```python
z
```

pylint crashed with a ``z*`` and with the following stacktrace:
```
a)filez```
z0Can't write the issue template for the crash in .)r   r   r   nowstrftimestrresolveopenreadexists	__class__r   write	traceback	print_excFileNotFoundErrorprint)r   r   r   issue_template_pathffile_contenttemplater   r   r   prepare_crash_report   s:   


r(   r$   c                 C   s   d|  d| dS )NzFatal error while checking 'zs'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'z'.r   )r   r$   r   r   r   get_fatal_error_message?   s   r)   c           	      C   s(  d}|t | k r| | }|ds|d7 }ntz|dd dd\}}W n ty6   |dd d}}Y nw z|| \}}W n tyL   |d7 }Y n>w | |= |ru|du ru|t | ksc| | drmd| d	}t|| | }| |= n|s|durd| d
}t|||| |t | k sdS dS )zlook for some options (keys of <search_for>) which have to be processed
    before others

    values of <search_for> are callback functions to call when the option is
    found
    r   z--      N=-zOption z expects a valuez doesn't expects a value)len
startswithsplit
ValueErrorKeyErrorr   )	args
search_foriargoptionvalcbtakeargmsgr   r   r   preprocess_optionsG   s6   


r<   c                 C   sZ   t tj}g }t }| D ]}t|}||vr || || q|tj tjd d < |S )N)listsyspathsetr   appendadd)r3   originalchangesseenr6   r?   r   r   r   _patch_sys_pathj   s   


rF   c              
   c   s6    t | }zdV  W |tjdd< dS |tjdd< w )aB  Prepare sys.path for running the linter checks.

    Within this context, each of the given arguments is importable.
    Paths are added to sys.path in corresponding order to the arguments.
    We avoid adding duplicate directories to sys.path.
    `sys.path` is reset to its original value upon exiting this context.
    N)rF   r>   r?   )r3   rC   r   r   r   fix_import_pathx   s
   	"rG   )
contextlibr>   r    r   pathlibr   pylint.configr   pylint.lint.expand_modulesr   	Exceptionr   r   r(   r)   r<   rF   contextmanagerrG   r   r   r   r   <module>   s   -#