Website : rimsha.abasa.com
backdoor
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
proc
/
self
/
root
/
lib
/
python3
/
dist-packages
/
docutils
/
utils
/
__pycache__
/
Filename :
code_analyzer.cpython-310.pyc
back
Copy
o �-$`r � @ s� d Z ddlmZ zddlZddlmZ ddlmZ dZW n e y' dZY nw g d�Z G d d � d e�ZG dd� de�Z G d d� de�ZdS )z@Lexical analysis of formal languages (i.e. code) using Pygments.� )�ApplicationErrorN)�get_lexer_by_name)�_get_ttype_classTF)�token�text� c @ s e Zd ZdS )� LexerErrorN)�__name__� __module__�__qualname__� r r �>/usr/lib/python3/dist-packages/docutils/utils/code_analyzer.pyr s r c @ s* e Zd ZdZd dd�Zdd� Zdd� Zd S )�Lexera� Parse `code` lines and yield "classified" tokens. Arguments code -- string of source code to parse, language -- formal language the code is written in, tokennames -- either 'long', 'short', or 'none' (see below). Merge subsequent tokens of the same token-type. Iterating over an instance yields the tokens as ``(tokentype, value)`` tuples. The value of `tokennames` configures the naming of the tokentype: 'long': downcased full token type name, 'short': short name defined by pygments.token.STANDARD_TYPES (= class argument used in pygments html output), 'none': skip lexical analysis. �shortc C sj || _ || _|| _d| _|dv s|dkrdS tstd��z t| j�| _W dS tjj y4 td| ��w )zE Set up a lexical analyzer for `code` in `language`. N)r r �nonez0Cannot analyze code. Pygments package not found.z6Cannot analyze code. No Pygments lexer found for "%s".) �code�language� tokennames�lexer� with_pygmentsr r �pygments�util� ClassNotFound)�selfr r r r r r �__init__0 s ��zLexer.__init__c c sv � t |�}t|�\}}|D ]\}}||u r||7 }q ||fV ||}}q |�d�r0|dd� }|r9||fV dS dS )zrMerge subsequent tokens of same token-type. Also strip the final newline (added by pygments). � N���)�iter�next�endswith)r �tokens�lasttype�lastval�ttype�valuer r r �mergeK s � �zLexer.mergec c s� � | j du rg | jfV dS t�| j| j �}| �|�D ]$\}}| jdkr.t|��� �d�}nt |�g}dd� |D �}||fV qdS )z7Parse self.code and yield "classified" tokens. N�long�.c S s g | ]}|t vr|�qS r )�unstyled_tokens)�.0�clsr r r � <listcomp>i s z"Lexer.__iter__.<locals>.<listcomp>) r r r �lexr% r �str�lower�splitr )r r � tokentyper$ �classesr r r �__iter__] s � �zLexer.__iter__N)r )r r r �__doc__r r% r2 r r r r r s r c @ s e Zd ZdZdd� Zdd� ZdS )�NumberLinesat Insert linenumber-tokens at the start of every code line. Arguments tokens -- iterable of ``(classes, value)`` tuples startline -- first line number endline -- last line number Iterating over an instance yields the tokens with a ``(['ln'], '<the line number>')`` token added for every code line. Multi-line tokens are splitted.c C s"