B
ӣ ؍ @ s( d dl Z ddlmZ G dd deZdS ) N )method_cachec sr e Zd ZdZdd Zdd Zdd Zdd Zd
d Z fdd
Z dd Z
e fddZdd Z
dddZ 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)selfother r I/opt/alt/python37/lib/python3.7/site-packages/importlib_metadata/_text.py__lt__C s zFoldedCase.__lt__c C s | | kS )N)r )r r r r r __gt__F s zFoldedCase.__gt__c C s | | kS )N)r )r r r r r __eq__I s zFoldedCase.__eq__c C s | | kS )N)r )r r r r r __ne__L s zFoldedCase.__ne__c C s t | S )N)hashr )r r r r __hash__O s zFoldedCase.__hash__c s t t| | S )N)superr r __contains__)r r ) __class__r r r R s zFoldedCase.__contains__c C s | t |kS )zDoes self appear in other?)r )r r r r r in_U s zFoldedCase.in_c s t t| S )N)r r r )r )r r r r Z s zFoldedCase.lowerc C s | | S )N)r index)r subr r r r ^ s zFoldedCase.index r c C s t t |t j}|| |S )N)recompileescapeIsplit)r splittermaxsplitpatternr 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