o
    g00                     @   sj  zd dl ZdZW n ey   d dlZdZY nw d dlZd dlZd dlZd dlZd dlZd dl	Z	d dl
mZmZ d dlmZmZmZmZmZmZmZmZmZ d dlmZmZmZ d dlmZ ejdkrjd d	lmZ nd d	lmZ erxd d
l m!Z! dZ"ed Z#ed Z$ed Z%ed Z&ed Z'ee#e$e%e&e'f Z(ede)e*ee+ eee*df Z,e"dfddZ-g dZ.dd Z/dd Z0dd Z1dd Z2dPdd Z3d!d" Z4	#dQd$eeef d%e+d&ed# d'ej5fd(d)Z6d*ejd'ee	j7 fd+d,Z8d-d. Z9e	dPd/d0d1e#d2ee) d'e)fd3d4Z:e	dPd/d0d1e$d2ee* d'e*fd5d4Z:e	dPd/d0d1e%d2eee+  d'ee+ fd6d4Z:e	dPd/d0d1e&d2ee d'efd7d4Z:e	dPd/d0d1e'd2eee*df  d'ee*df fd8d4Z:	dPd/d0d1e(d2ee, d'ee, fd9d4Z:	dRd:d;Z;dSd=d>Z<d?d@ Z=dAdB Z>dCdD Z?dEdF Z@	dPd$edGe+dHee dIee+ d'df
dJdKZAd$edHee d'dfdLdMZBG dNdO dOZCdS )T    NTF)BufferedReaderBytesIO)	TYPE_CHECKINGListOptionalPatternTextIOTupleTypeVarUnionoverload)Modulemodutilsnodes)PY_EXTS)      )Literal)BaseCheckerO   )zignore-mixin-memberszsuggestion-modezanalyse-fallback-blockszallow-global-unused-variables)zmax-line-lengthzdocstring-min-lengthzignored-modules)zno-docstring-rgxzdummy-variables-rgxzignored-argument-namesz
py-versionT_GlobalOptionReturnTypes. c                 C   s   d tj| |||dS )z'Wrap the text on the given line length.
)widthinitial_indentsubsequent_indent)jointextwrapwrap)textline_lenindent r"   P/home/ubuntu/cloudmapper/venv/lib/python3.10/site-packages/pylint/utils/utils.pynormalize_textH   s
   r$   )=-+c                 C   s   | |k| |k  S Nr"   )abr"   r"   r#   cmpU   s   r+   c                 C   s2   t | | }tt| |  |r|dpd }|S )zTgiven an old and new int value, return a string representing the
    difference
    z.2fr   )absCMPSr+   )oldnewdiffdiff_strr"   r"   r#   diff_stringY   s   "r2   c                 C   sv   |   }dg }}|r0t|tr|j}n	|t|dd z|j  }W n	 ty-   Y nw |s|  |d	|fS )z5return the module name and the frame id in the moduler   namez<lambda>.)
frame
isinstancer   r3   appendgetattrparentAttributeErrorreverser   )noder5   moduleobjr"   r"   r#   get_module_and_frameidb   s   

	r?   c                 C   s   |  d|t |   dS )z^Permit to get a title formatted as ReStructuredText test (underlined with a chosen character).r   )len)title	characterr"   r"   r#   get_rst_titles   s   rC   c           
      C   s   d}| r|t | d7 }|rt|}|| d7 }|D ]6\}}}|d}|d| d7 }|r;t|dd}	||	 d	7 }|rPtt||}|d
|dd d7 }q|S )zFformat an options section using as a ReStructuredText formatted outputr   'z

help:z:
z  r!   r   z
  Default: ``z`` z```` ``z``
)rC   r$   getstr_format_option_valuereplace)
sectionoptionsdocresultformatted_docoptnameoptdictvaluehelp_optformatted_helpr"   r"   r#   get_rst_sectionx   s"   
rV   c                 O   sR   z| j |pt g|R i |W S  ty(   | j t g|R i | Y S w )zAreturn decoded line from encoding or decode with default encoding)decodesysgetdefaultencodingLookupError)lineencodingargskwargsr"   r"   r#   safe_decode   s
   " r_   strictstreamr\   errorsreturnc                 C   sB   zt |pt }W n ty   t t }Y nw || |S r(   )codecs	getreaderrX   rY   rZ   )ra   r\   rb   
reader_clsr"   r"   r#   decoding_stream   s   
rg   r<   c                 C   s@   |   }|j}tt|W  d    S 1 sw   Y  d S r(   )ra   readlinelisttokenize)r<   ra   rh   r"   r"   r#   tokenize_module   s   
$rk   c                 C   s   i }t |D ]o}t j|\}}||v s|dkrq|tv r"|dks4|svt jt j||rv|dsvzt	t j||}W n' t
yI   Y q tyg } ztd| d| tjd W Y d}~qd}~ww t|drv||  d	||< qdS )
zload all module and package in the given directory, looking for a
    'register' function in each one, used to register pylint checkers
    __pycache____init__r4   zProblem importing module z: fileNregister   )oslistdirpathsplitextr   isdirr   
startswithr   load_module_from_file
ValueErrorImportErrorprintrX   stderrhasattrrp   )linter	directoryimportedfilenamebase	extensionr=   excr"   r"   r#   register_plugins   s8   &

r   checkerr   optiondefaultc                 C      d S r(   r"   r   r   r   r"   r"   r#   get_global_option      r   c                 C   r   r(   r"   r   r"   r"   r#   r      r   c                 C   r   r(   r"   r   r"   r"   r#   r         c                 C   r   r(   r"   r   r"   r"   r#   r      r   c                 C   r   r(   r"   r   r"   r"   r#   r      r   c                 C   sp   zt | j|ddW S  ty   Y nw | jjD ]}|jD ]}|d |kr4t |j|dd    S qq|S )a  Retrieve an option defined by the given *checker* or
    by all known option providers.

    It will look in the list of all options providers
    until the given *option* will be found.
    If the option wasn't found, the *default* value will be returned.
    r&   _r   )r8   configrK   r:   r~   options_providersrM   )r   r   r   providerrM   r"   r"   r#   r      s   
c                    s.    fdd}|d|d|dd}| r| |d< |S )Nc                    s    rt j |f  d S d S r(   )rX   r|   write)r   rQ   r]   deprecation_msgr"   r#   _warn_deprecated  s   z+deprecated_option.<locals>._warn_deprecatedTcallback)rE   hidetypeactionr   
deprecated	shortnamer"   )r   opt_typehelp_msgr   r   r   r"   r   r#   deprecated_option
  s   r   ,c                 C   s   dd |  |D S )a%  return a list of stripped string by splitting the string given as
    argument on `sep` (',' by default). Empty string are discarded.

    >>> _splitstrip('a, b, c   ,  4,,')
    ['a', 'b', 'c', '4']
    >>> _splitstrip('a')
    ['a']
    >>> _splitstrip('a,
b,
c,')
    ['a', 'b', 'c']

    :type string: str or unicode
    :param string: a csv line

    :type sep: str or unicode
    :param sep: field separator, default to the comma (',')

    :rtype: str or unicode
    :return: the unquoted string (or the input string if it wasn't quoted)
    c                 S   s   g | ]
}|  r|  qS r"   strip).0wordr"   r"   r#   
<listcomp>2  s    z_splitstrip.<locals>.<listcomp>)split)stringsepr"   r"   r#   _splitstrip  s   r   c                 C   s<   | s| S | d dv r| dd } | d dv r| dd } | S )zremove optional quotes (simple or double) from the string

    :type string: str or unicode
    :param string: an optionally quoted string

    :rtype: str or unicode
    :return: the unquoted string (or the input string if it wasn't quoted)
    r   z"'rq   Nr"   )r   r"   r"   r#   _unquote5  s   	r   c                 C   s   t | ttfr	| S t| S r(   )r6   ri   tupler   )rS   r"   r"   r#   
_check_csvG  s   r   c                 C   s(   dd |   D }dtj d| S )zreturn string as a commentc                 S   s   g | ]}|  qS r"   r   )r   r[   r"   r"   r#   r   O  s    z_comment.<locals>.<listcomp># )
splitlinesrr   linesepr   )r   linesr"   r"   r#   _commentM  s   r   c                    s     dddkrddd |D }|S t|ttfr)d fdd|D }|S t|tr<dd	d | D }|S t|d
rF|j}|S   ddkrW|rSd}|S d}|S t|t	rf|
 rfd| d}|S )z5return the user input's value from a 'compiled' valuer   N
py_versionr4   c                 s   s    | ]}t |V  qd S r(   )rI   r   itemr"   r"   r#   	<genexpr>V      z'_format_option_value.<locals>.<genexpr>r   c                 3   s    | ]}t  |V  qd S r(   )rJ   r   rR   r"   r#   r   X  s    c                 s   s"    | ]\}}| d | V  qdS )rF   Nr"   )r   kvr"   r"   r#   r   Z  s     matchynyesnorD   )rH   r   r6   ri   r   dictitemsr}   patternrI   isspace)rR   rS   r"   r   r#   rJ   S  s(   


rJ   rL   rM   rN   c                 C   s6   |r
t t|| d t d| d| d t| | dS )z.format an options section using the INI formatrn   []N)r{   r   _ini_format)ra   rL   rM   rN   r"   r"   r#   format_sectione  s   r   c                 C   s   |D ]m\}}}t ||}|d}|r%t|dd}t| d t|| d nt| d |du r9td| d| d qt| }tdt|rdd	d
t|  }|	dd t|
dD }|dd }t| d| | d qdS )z#format options using the INI formatrE   r   rG   rn   N#r%   z^([\w-]+,)+[\w-]+$z
  c                 s   s    | ]}|d  V  qdS )r   Nr"   )r   xr"   r"   r#   r     r   z_ini_format.<locals>.<genexpr>r   r   )rJ   rH   r$   r{   rI   r   rer   r@   r   r   )ra   rM   rQ   rR   rS   rT   	separatorr"   r"   r#   r   o  s"   



r   c                   @   s    e Zd ZdZdd Zdd ZdS )IsortDriverzAA wrapper around isort API that changed between versions 4 and 5.c                 C   s8   t rtjj|j|jd| _d S tjd|j|jd| _d S )N)extra_standard_libraryknown_third_partyr   )file_contentsknown_standard_libraryr   )	HAS_ISORT_5isortapiConfigr   r   isort5_configSortImports
isort4_obj)selfr   r"   r"   r#   rm     s   	zIsortDriver.__init__c                 C   s    t r
tj|| jS | j|S r(   )r   r   r   place_moduler   r   )r   packager"   r"   r#   r     s   zIsortDriver.place_moduleN)__name__
__module____qualname____doc__rm   r   r"   r"   r"   r#   r     s    r   r(   )r`   )NNNN)r   )D	isort.apir   r   rz   rd   rr   r   rX   r   rj   ior   r   typingr   r   r   r   r   r	   r
   r   r   astroidr   r   r   pylint.constantsr   version_infor   typing_extensionspylint.checkers.base_checkerr   DEFAULT_LINE_LENGTHGLOBAL_OPTION_BOOLGLOBAL_OPTION_INTGLOBAL_OPTION_LISTGLOBAL_OPTION_PATTERNGLOBAL_OPTION_TUPLE_INTGLOBAL_OPTION_NAMESboolintrI   r   r$   r-   r+   r2   r?   rC   rV   r_   StreamReaderrg   	TokenInfork   r   r   r   r   r   r   r   rJ   r   r   r   r"   r"   r"   r#   <module>   s*  ,
		


!






