
    2 f{                         d 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
mZ ddlmZ ddlmZ dd	lmZ d
dgZdZdZdZ G d de          ZdS )a  EditorConfig file parser

Based on code from ConfigParser.py file distributed with Python 2.6.

Licensed under PSF License (see LICENSE.PSF file).

Changes to original ConfigParser:

- Special characters can be used in section names
- Octothorpe can be used for comments (not just at beginning of line)
- Only track INI options in sections that match target filename
- Stop parsing files with when ``root = true`` is found

    N)open)OrderedDict)sep)dirnamenormpath)u)ParsingError)fnmatchr	   EditorConfigParseri   2      c                       e Zd ZdZ ej        dej                  Z ej        dej                  Zd Z	d Z
d Zd Zd Zd	S )
r   zxParser for EditorConfig-style configuration files

    Based on RawConfigParser from ConfigParser.py in Python 2.6.
    ay  

        \s *                                # Optional whitespace
        \[                                  # Opening square brace

        (?P<header>                         # One or more characters excluding
            ( [^\#;] | \\\# | \\; ) +       # unescaped # and ; characters
        )

        \]                                  # Closing square brace

        a  

        \s *                                # Optional whitespace
        (?P<option>                         # One or more characters excluding
            [^:=\s]                         # : a = characters (and first
            [^:=] *                         # must not be whitespace)
        )
        \s *                                # Optional whitespace
        (?P<vi>
            [:=]                            # Single = or : character
        )
        \s *                                # Optional whitespace
        (?P<value>
            . *                             # One or more characters
        )
        $

        c                 H    || _         t                      | _        d| _        d S )NF)filenamer   options	root_file)selfr   s     F/var/www/equiseq/venv/lib/python3.11/site-packages/editorconfig/ini.py__init__zEditorConfigParser.__init__S   s     "}}    c                    t          t          |                                        t          d          }|                    dd          }|                    dd          }d|v r9|                    d          dk    r
|dd         }t          j        ||          }nt          j        d	|          }t          | j        |          S )
z,Return True if section glob matches filename/z\##z\;;r      Nz**/)	r   r   replacer   find	posixpathjoinr
   r   )r   config_filenameglobconfig_dirnames       r   matches_filenamez#EditorConfigParser.matches_filenameX   s    !'/":":;;CCCMM||E3''||E3''$;;yy~~""ABBx>.$77DD>%..Dt}d+++r   c                     	 t          |d          }n# t          $ r Y dS w xY w|                     ||           |                                 dS )z'Read and parse single EditorConfig filezutf-8)encodingN)r   IOError_readclose)r   r   fps      r   readzEditorConfigParser.reade   sb    	h111BB 	 	 	FF	

2x   





s    
""c                 d   d}d}d}d}d}	 |                                 }|sn|dk    r,|                    t          d                    r
|dd         }|dz   }|                                dk    s
|d         dv rs| j                            |          }	|	rJ|	                    d	          }
t          |
          t          k    rd}| 	                    ||
          }d}nF| j
                            |          }	|	r|	                    d
dd          \  }}}d|v sd|v r,t          j        d|          }|r|                    d          }|                                }|dk    rd}|                     |                                          }t          |          t          k    st          |          t           k    r|s#|dk    r|                                dk    | _        |r
|| j        |<   n4|st)          |          }|                    |t-          |                      |r|dS )a  Parse a sectioned setup file.

        The sections in setup file contains a title line at the top,
        indicated by a name in square brackets (`[]'), plus key/value
        options lines, indicated by `name: value' format lines.
        Continuations are represented by an embedded newline then
        leading whitespace.  Blank lines, lines beginning with a '#',
        and just about everything else are ignored.
        FNr   Tu   ﻿r    z#;headeroptionvivaluer   r   z
(.*?) [;#]z""roottrue)readline
startswithr   stripSECTCREmatchgrouplenMAX_SECTION_LENGTHr#   OPTCREresearchoptionxformrstripMAX_PROPERTY_LENGTHMAX_VALUE_LENGTHlowerr   r   r	   appendrepr)r   r)   fpname
in_sectionmatching_sectionoptnamelinenoelinemosectnamer/   optvalms                 r   r'   zEditorConfigParser._readn   s[    
 4	5;;==D {{tq{{;;{ABBxaZFzz||r!!T!W__ \''-- &5!xx11H8}}'999 !%J'+'<'<VX'N'N$"GG **400B 5.0hhxw.O.O+V&==C6MM !#	, ? ?A  4)*!'!T>>%'F"&"2"27>>3C3C"D"DLL+>>>KK*:::$) Hg.?.?.4llnn.FDN+ ;4:DL1  ! 5 ,V 4 4Ad444i4	5l  	G	 	r   c                 *    |                                 S )N)rB   )r   	optionstrs     r   r>   zEditorConfigParser.optionxform   s       r   N)__name__
__module____qualname____doc__r<   compileVERBOSEr6   r;   r   r#   r*   r'   r>    r   r   r   r   #   s          bj	 Z G$ RZ	" Z% F*  
, , ,  F F FP! ! ! ! !r   )rU   r   r<   codecsr   collectionsr   osr   os.pathr   r   editorconfig.compatr   editorconfig.exceptionsr	   editorconfig.fnmatchr
   __all__r:   r@   rA   objectr   rX   r   r   <module>rb      s        				       # # # # # #       % % % % % % % % ! ! ! ! ! ! 0 0 0 0 0 0 ( ( ( ( ( ( /
0   T! T! T! T! T! T! T! T! T! T!r   