File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/zipp.tar
Back
glob.py 0000644 00000006012 15030222101 0006022 0 ustar 00 import os import re _default_seps = os.sep + str(os.altsep) * bool(os.altsep) class Translator: """ >>> Translator('xyz') Traceback (most recent call last): ... AssertionError: Invalid separators >>> Translator('') Traceback (most recent call last): ... AssertionError: Invalid separators """ seps: str def __init__(self, seps: str = _default_seps): assert seps and set(seps) <= set(_default_seps), "Invalid separators" self.seps = seps def translate(self, pattern): """ Given a glob pattern, produce a regex that matches it. """ return self.extend(self.translate_core(pattern)) def extend(self, pattern): r""" Extend regex for pattern-wide concerns. Apply '(?s:)' to create a non-matching group that matches newlines (valid on Unix). Append '\Z' to imply fullmatch even when match is used. """ return rf'(?s:{pattern})\Z' def translate_core(self, pattern): r""" Given a glob pattern, produce a regex that matches it. >>> t = Translator() >>> t.translate_core('*.txt').replace('\\\\', '') '[^/]*\\.txt' >>> t.translate_core('a?txt') 'a[^/]txt' >>> t.translate_core('**/*').replace('\\\\', '') '.*/[^/][^/]*' """ self.restrict_rglob(pattern) return ''.join(map(self.replace, separate(self.star_not_empty(pattern)))) def replace(self, match): """ Perform the replacements for a match from :func:`separate`. """ return match.group('set') or ( re.escape(match.group(0)) .replace('\\*\\*', r'.*') .replace('\\*', rf'[^{re.escape(self.seps)}]*') .replace('\\?', r'[^/]') ) def restrict_rglob(self, pattern): """ Raise ValueError if ** appears in anything but a full path segment. >>> Translator().translate('**foo') Traceback (most recent call last): ... ValueError: ** must appear alone in a path segment """ seps_pattern = rf'[{re.escape(self.seps)}]+' segments = re.split(seps_pattern, pattern) if any('**' in segment and segment != '**' for segment in segments): raise ValueError("** must appear alone in a path segment") def star_not_empty(self, pattern): """ Ensure that * will not match an empty segment. """ def handle_segment(match): segment = match.group(0) return '?*' if segment == '*' else segment not_seps_pattern = rf'[^{re.escape(self.seps)}]+' return re.sub(not_seps_pattern, handle_segment, pattern) def separate(pattern): """ Separate out character sets to avoid translating their contents. >>> [m.group(0) for m in separate('*.txt')] ['*.txt'] >>> [m.group(0) for m in separate('a[?]txt')] ['a', '[?]', 'txt'] """ return re.finditer(r'([^\[]+)|(?P<set>[\[].*?[\]])|([\[][^\]]*$)', pattern) __pycache__/__init__.cpython-310.pyc 0000644 00000037502 15030222101 0013205 0 ustar 00 o �hd4 � @ s� d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZddl m Z ddlmZ dgZ dd� Zdd � ZejZ d d� ZG dd � d �ZG dd� d�ZG dd� deeej�ZG dd� de�Zddd�ZG dd� d�ZdS )� N� )� text_encoding)� Translator�Pathc C s t �t| �dd�S )a2 Given a path with elements separated by posixpath.sep, generate all parents of that path. >>> list(_parents('b/d')) ['b'] >>> list(_parents('/b/d/')) ['/b'] >>> list(_parents('b/d/f/')) ['b/d', 'b'] >>> list(_parents('b')) [] >>> list(_parents('')) [] r N)� itertools�islice� _ancestry)�path� r �S/usr/local/CyberCP/lib/python3.10/site-packages/setuptools/_vendor/zipp/__init__.py�_parents s r c c sN � | � tj�} | r!| tjkr%| V t�| �\} }| r#| tjksdS dS dS dS )aR Given a path with elements separated by posixpath.sep, generate all elements of that path >>> list(_ancestry('b/d')) ['b/d', 'b'] >>> list(_ancestry('/b/d/')) ['/b/d', '/b'] >>> list(_ancestry('b/d/f/')) ['b/d/f', 'b/d', 'b'] >>> list(_ancestry('b')) ['b'] >>> list(_ancestry('')) [] N)�rstrip� posixpath�sep�split)r �tailr r r r % s ��r c C s t �t|�j| �S )zZ Return items in minuend not in subtrahend, retaining order with O(1) lookup. )r �filterfalse�set�__contains__)�minuend� subtrahendr r r �_difference? s r c s4 e Zd ZdZ� fdd�Zdd� Z� fdd�Z� ZS )�InitializedStatez? Mix-in to save the initialization state for pickling. c s"