/ lib / soupsieve / pretty.pyc
pretty.pyc
 1  o

 2  t�c��@s�dZddlZddlmZe�d�Ze�d�Ze�d�Ze�d�Ze�d�Z	e�d	�Z
 3  e�d
 4  �Ze�d�Ze�d�Z
e�d
�Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�Zeeeee	e
 5  eee
eeeeeed�Zdedefdd�ZdS)a�
 6  Format a pretty string of a `SoupSieve` object for easy debugging.
 7  
 8  This won't necessarily support all types and such, and definitely
 9  not support custom outputs.
10  
11  It is mainly geared towards our types as the `SelectorList`
12  object is a beast to look at without some indentation and newlines.
13  The format and various output types is fairly known (though it
14  hasn't been tested extensively to make sure we aren't missing corners).
15  
16  Example:
17  
18  ```
19  >>> import soupsieve as sv
20  >>> sv.compile('this > that.class[name=value]').selectors.pretty()
21  SelectorList(
22      selectors=(
23          Selector(
24              tag=SelectorTag(
25                  name='that',
26                  prefix=None),
27              ids=(),
28              classes=(
29                  'class',
30                  ),
31              attributes=(
32                  SelectorAttribute(
33                      attribute='name',
34                      prefix='',
35                      pattern=re.compile(
36                          '^value$'),
37                      xml_type_pattern=None),
38                  ),
39              nth=(),
40              selectors=(),
41              relation=SelectorList(
42                  selectors=(
43                      Selector(
44                          tag=SelectorTag(
45                              name='this',
46                              prefix=None),
47                          ids=(),
48                          classes=(),
49                          attributes=(),
50                          nth=(),
51                          selectors=(),
52                          relation=SelectorList(
53                              selectors=(),
54                              is_not=False,
55                              is_html=False),
56                          rel_type='>',
57                          contains=(),
58                          lang=(),
59                          flags=0),
60                      ),
61                  is_not=False,
62                  is_html=False),
63              rel_type=None,
64              contains=(),
65              lang=(),
66              flags=0),
67          ),
68      is_not=False,
69      is_html=False)
70  ```
71  �N)�Anyz(?i)[a-z_][_a-z\d\.]+\(z(?i)[_a-z][_a-z\d]+=z\(\)|\[\]|\{\}z\[z\{z\(z\]z\}z\)z\d+z(?i)[_a-z][_a-z\d]+z"(?:\\.|[^"\\])*"z'(?:\\.|[^'\\])*'z	\s*(,)\s*z	\s*(:)\s*)�class�param�empty�lstrt�dstrt�tstrt�lend�dend�tend�sqstr�sep�dsep�int�kword�dqstr�obj�returnc
72  Cs t|�}d}t|�d}d}g}||kr�d}t��D]l\}}|�||�}|r�|}	|�d�}|	dvrD|d7}|�d�|�d�d|��n@|	dvrQ|�|�d��n3|	d	vrb|d8}|�|�d��n"|	d
73  vru|�d�|�d�d|��n|	dvr�|�d�|�d���nq||ksd
�	|�S)z%Make the object output string pretty.r�N)rrrr�z{}
74  {}� )rrrrrr)r	r
75  r)r
)rz{} �)
76  �str�len�TOKENS�items�match�end�append�format�group�join)
77  r�sel�indexr�indent�output�m�k�v�name�r*��C:\Users\Jacks.GUTTSPC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\soupsieve\pretty.py�prettyjs8
78  ��
79  r,)�__doc__�re�typingr�compile�RE_CLASS�RE_PARAM�RE_EMPTY�RE_LSTRT�RE_DSTRT�RE_TSTRT�RE_LEND�RE_DEND�RE_TEND�RE_INT�RE_KWORD�RE_DQSTR�RE_SQSTR�RE_SEP�RE_DSEPrrr,r*r*r*r+�<module>sFC
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  �