File: //opt/saltstack/salt/lib/python3.10/site-packages/jaraco/text/__pycache__/__init__.cpython-310.pyc
o
�N�g�6 � @ s" d dl Z d dlZd dlZd dlZzd dlmZ W n
ey% d dlZY nw d dlm Z m
Z
dd� Zdd� ZG dd � d e
�Zd
d� Zdd
� Zdd� Zdd� Zdd� Ze�ed�ZG dd� de�Zd(dd�ZG dd� de�ZejZdd� ZG dd� de
�ZG d d!� d!�Z d"d#� Z!d$d%� Z"d&d'� Z#dS ))� N)� resources)�compose�method_cachec s � �fdd�S )zH
Return a function that will perform a substitution on a string
c s | � �� �S �N��replace��s��new�old� �H/opt/saltstack/salt/lib/python3.10/site-packages/jaraco/text/__init__.py�<lambda> s zsubstitution.<locals>.<lambda>r
)r r r
r
r �substitution s r c G s t �t| �} tt| ��} t| � S )z�
Take a sequence of pairs specifying substitutions, and create
a function that performs those substitutions.
>>> multi_substitution(('foo', 'bar'), ('bar', 'baz'))('foo')
'baz'
)� itertools�starmapr �reversed�tupler )Z
substitutionsr
r
r �multi_substitution s r c sr e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
d� Z� fdd
�Z dd� Z
e� fdd��Zdd� Z
ddd�Z� ZS )�
FoldedCasea
A case insensitive string class; behaves just like str
except compares equal when the only variation is case.
>>> s = FoldedCase('hello world')
>>> s == 'Hello World'
True
>>> 'Hello World' == s
True
>>> s != 'Hello World'
False
>>> s.index('O')
4
>>> s.split('O')
['hell', ' w', 'rld']
>>> sorted(map(FoldedCase, ['GAMMA', 'alpha', 'Beta']))
['alpha', 'Beta', 'GAMMA']
Sequence membership is straightforward.
>>> "Hello World" in [s]
True
>>> s in ["Hello World"]
True
You may test for set inclusion, but candidate and elements
must both be folded.
>>> FoldedCase("Hello World") in {s}
True
>>> s in {FoldedCase("Hello World")}
True
String inclusion works as long as the FoldedCase object
is on the right.
>>> "hello" in FoldedCase("Hello World")
True
But not if the FoldedCase object is on the left:
>>> FoldedCase('hello') in 'Hello World'
False
In that case, use ``in_``:
>>> FoldedCase('hello').in_('Hello World')
True
>>> FoldedCase('hello') > FoldedCase('Hello')
False
c C s | � � |� � k S r ��lower��self�otherr
r
r �__lt__` � zFoldedCase.__lt__c C s | � � |� � kS r r r r
r
r �__gt__c r zFoldedCase.__gt__c C s | � � |� � kS r r r r
r
r �__eq__f r zFoldedCase.__eq__c C s | � � |� � kS r r r r
r
r �__ne__i r zFoldedCase.__ne__c C s t | �� �S r )�hashr �r r
r
r �__hash__l � zFoldedCase.__hash__c s t t| ��� �|�� �S r )�superr r �__contains__r �� __class__r
r r&