o
0¦i– ã @ s( d dl Z ddlmZ G dd„ deƒZdS )é Né )Úmethod_cachec 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 ©N©Úlower©ÚselfÚother© r ú?/opt/alt/python310/lib64/python3.10/importlib/metadata/_text.pyÚ__lt__C ó zFoldedCase.__lt__c C s | ¡ | ¡ kS r r r r r r Ú__gt__F r zFoldedCase.__gt__c C s | ¡ | ¡ kS r r r r r r Ú__eq__I r zFoldedCase.__eq__c C s | ¡ | ¡ kS r r r r r r Ú__ne__L r zFoldedCase.__ne__c C s t | ¡ ƒS r )Úhashr ©r r r r Ú__hash__O s zFoldedCase.__hash__c s t t| ƒ ¡ | ¡ ¡S r )Úsuperr r Ú__contains__r ©Ú __class__r r r R s zFoldedCase.__contains__c C s | t |ƒv S )zDoes self appear in other?)r r r r r Úin_U s zFoldedCase.in_c s t t| ƒ ¡ S r )r r r r r r r r Z s zFoldedCase.lowerc C s | ¡ | ¡ ¡S r )r Úindex)r Úsubr r r r ^ s zFoldedCase.indexú r c C s t t |¡t j¡}| | |¡S r )ÚreÚcompileÚescapeÚIÚsplit)r ZsplitterÚmaxsplitÚpatternr r r r! a s zFoldedCase.split)r r )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r
r r r r r r r r r r! Ú
__classcell__r r r r r s ;r )r Ú
_functoolsr Ústrr r r r r Ú