/
lib
/
python3
/
dist-packages
/
debian
/
_deb822_repro
/
__pycache__
/
Upload File
HOME
� )uyc�? � � � d dl Z d dlZd dlmZ d dlZd dlmZmZ d dlmZ d dl m Z mZmZm Z mZmZmZ n# e$ r dZd� ZY nw xY werd dlmZ e j d e j � � Z e j d e j � � Z e j de j � � Z G d� d � � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z G d� de� � Z! G d� de� � Z" G d � d!e� � Z# G d"� d#e"� � Z$ G d$� d%e"� � Z% G d&� d'e� � Z& G d(� d)e� � Z' G d*� d+e� � Z(d1d-�Z)d.� Z*e*d/� � � Z+e*d0� � � Z,dS )2� N)� ReferenceType)�resolve_ref�_strI)�BufferingIterator)�Optional�cast� TYPE_CHECKING�Iterable�Union�Dict�CallableFc � � |S �N� )�t�vs �=/usr/lib/python3/dist-packages/debian/_deb822_repro/tokens.py�<lambda>r s � �� � )� Deb822Elementa� (?P<space_before>\s*) # Consume any whitespace before the word # The space only occurs in practise if the line starts # with space. # Optionally consume a word (needed to handle the case # when there are no words left and someone applies this # pattern to the remaining text). This is mostly here as # a fail-safe. (?P<word>\S+) # Consume the word (if present) (?P<trailing_whitespace>\s*) # Consume trailing whitespace a� # This regex is slightly complicated by the fact that it should work with # finditer and comsume the entire value. # # To do this, we structure the regex so it always starts on a comma (except # for the first iteration, where we permit the absence of a comma) (?: # Optional space followed by a mandatory comma unless # it is the start of the "line" (in which case, we # allow the comma to be omitted) ^ | (?: (?P<space_before_comma>\s*) # This space only occurs in practise if the line # starts with space + comma. (?P<comma> ,) ) ) # From here it is "optional space, maybe a word and then optional space" again. One reason why # all of it is optional is to gracefully cope with trailing commas. (?P<space_before_word>\s*) (?P<word> [^,\s] (?: [^,]*[^,\s])? )? # "Words" can contain spaces for comma separated list. # But surrounding whitespace is ignored (?P<space_after_word>\s*) a� ^ # Start of line (?P<field_name> # Capture group for the field name [\x21\x22\x24-\x2C\x2F-\x39\x3B-\x7F] # First character [\x21-\x39\x3B-\x7F]* # Subsequent characters (if any) ) (?P<separator> : ) (?P<space_before_value> \s* ) (?: # Field values are not mandatory on the same line # as the field name. (?P<value> \S(?:.*\S)? ) # Values must start and end on a "non-space" (?P<space_after_value> \s* ) # We can have optional space after the value )? c � � e Zd ZdZdZd� Zd� Zd� Zed� � � Z ed� � � Z ed� � � Zd � Zed � � � Z e j d� � � Z d� Zd S )�Deb822Tokena> A token is an atomic syntactical element from a deb822 file A file is parsed into a series of tokens. If these tokens are converted to text in exactly the same order, you get exactly the same file - bit-for-bit. Accordingly ever bit of text in a file must be assigned to exactly one Deb822Token. )�_text�_parent_element�__weakref__c �t � |dk rt d� � �|| _ d | _ | � � � d S )N� zTokens must have content)� ValueErrorr r �_verify_token_text)�self�texts r �__init__zDeb822Token.__init__b sA � ��2�:�:��7�8�8�8��� �#������!�!�!�!�!r c �v � d� | j j | j � dd� � �� � S )Nz{clsname}('{text}')� z\n)�clsnamer! )�format� __class__�__name__r �replace�r s r �__repr__zDeb822Token.__repr__j s; � �$�+�+�D�N�4K�15��1C�1C�D�%�1P�1P� ,� .� .� .r c �& � d| j v r�d}| j st | t � � rd}|s| j st d� � �| j � d� � st d� � �|r"d| j d d� v rt d� � �d S d S d S )Nr$ FTz>Only whitespace, error and comment tokens may contain newlinesz2Tokens containing whitespace must end on a newline���zNComments and error tokens must not contain embedded newlines (only end on one))r � is_comment� isinstance�Deb822ErrorToken� is_whitespacer r! �endswith)r �is_single_line_tokens r r zDeb822Token._verify_token_textp s� � ��4�:���#(� ��� ,�*�T�3C�"D�"D� ,�'+�$�'� c��0B� c� �!a�b�b�b��9�%�%�d�+�+� W� �!U�V�V�V�#� 7��� �#�2�#��(>�(>� � "6� 7� 7� 7� �� 7� 7�(>�(>r c � � dS �NFr r* s r r1 zDeb822Token.is_whitespace~ � � � �ur c � � dS r5 r r* s r r. zDeb822Token.is_comment� r6 r c � � | j S r �r r* s r r! zDeb822Token.text� s � � �z�r c � � | j S r r9 r* s r �convert_to_textzDeb822Token.convert_to_text� s � ��z�r c �* � t | j � � S r )r r r* s r �parent_elementzDeb822Token.parent_element� s � � �4�/�0�0�0r c �@ � |�t j |� � nd | _ d S r )�weakref�refr )r � new_parents r r= zDeb822Token.parent_element� s( � � ;E�:P�w�{�:�6�6�6�VZ����r c �* � || j u r d | _ d S d S r )r= r )r �parents r �clear_parent_if_parentz"Deb822Token.clear_parent_if_parent� s&