Your IP : 3.137.171.71


Current Path : /opt/alt/python34/lib64/python3.4/lib2to3/fixes/__pycache__/
Upload File :
Current File : //opt/alt/python34/lib64/python3.4/lib2to3/fixes/__pycache__/fix_operator.cpython-34.pyc

�
i f�
�@smdZddlZddlmZddlmZmZmZmZdd�Z	Gdd�dej
�ZdS)	a�Fixer for operator functions.

operator.isCallable(obj)       -> hasattr(obj, '__call__')
operator.sequenceIncludes(obj) -> operator.contains(obj)
operator.isSequenceType(obj)   -> isinstance(obj, collections.Sequence)
operator.isMappingType(obj)    -> isinstance(obj, collections.Mapping)
operator.isNumberType(obj)     -> isinstance(obj, numbers.Number)
operator.repeat(obj, n)        -> operator.mul(obj, n)
operator.irepeat(obj, n)       -> operator.imul(obj, n)
�N)�
fixer_base)�Call�Name�String�touch_importcs�fdd�}|S)Ncs
�|_|S)N)�
invocation)�f)�s��?/opt/alt/python34/lib64/python3.4/lib2to3/fixes/fix_operator.py�decs	zinvocation.<locals>.decr
)r	rr
)r	rrsrc@seZdZdZdZdZdZdedede�Zdd	�Z	e
d
�dd��Ze
d
�dd��Ze
d�dd��Z
e
d�dd��Ze
d�dd��Ze
d�dd��Ze
d�dd��Zdd �Zd!d"�Zd#d$�Zd%S)&�FixOperatorTZprez�
              method=('isCallable'|'sequenceIncludes'
                     |'isSequenceType'|'isMappingType'|'isNumberType'
                     |'repeat'|'irepeat')
              z'(' obj=any ')'z�
              power< module='operator'
                trailer< '.' %(methods)s > trailer< %(obj)s > >
              |
              power< %(methods)s trailer< %(obj)s > >
              �methods�objcCs/|j||�}|dk	r+|||�SdS)N)�
_check_method)�self�node�results�methodr
r
r�	transform+szFixOperator.transformzoperator.contains(%s)cCs|j||d�S)N�contains)�_handle_rename)rrrr
r
r�_sequenceIncludes0szFixOperator._sequenceIncludeszhasattr(%s, '__call__')cCsG|d}|j�td�td�g}ttd�|d|j�S)Nrz, z
'__call__'�hasattr�prefix)�clonerrrr)rrrr�argsr
r
r�_isCallable4s
!zFixOperator._isCallablezoperator.mul(%s)cCs|j||d�S)N�mul)r)rrrr
r
r�_repeat:szFixOperator._repeatzoperator.imul(%s)cCs|j||d�S)N�imul)r)rrrr
r
r�_irepeat>szFixOperator._irepeatz$isinstance(%s, collections.Sequence)cCs|j||dd�S)N�collections�Sequence)�_handle_type2abc)rrrr
r
r�_isSequenceTypeBszFixOperator._isSequenceTypez#isinstance(%s, collections.Mapping)cCs|j||dd�S)Nr"�Mapping)r$)rrrr
r
r�_isMappingTypeFszFixOperator._isMappingTypezisinstance(%s, numbers.Number)cCs|j||dd�S)NZnumbers�Number)r$)rrrr
r
r�
_isNumberTypeJszFixOperator._isNumberTypecCs%|dd}||_|j�dS)Nrr)�valueZchanged)rrr�namerr
r
rrNs	zFixOperator._handle_renamecCsatd||�|d}|j�tddj||g��g}ttd�|d|j�S)Nrz, �.�
isinstancer)rrr�joinrrr)rrr�module�abcrrr
r
rr$Ss
+zFixOperator._handle_type2abccCs{t|d|ddj�}t|tj�rwd|kr@|St|d�f}|j|}|j|d|�ndS)N�_rrr/rzYou should use '%s' here.)�getattrr*r-r"�Callable�strrZwarning)rrrr�subZinvocation_strr
r
rrYs
zFixOperator._check_methodN)�__name__�
__module__�__qualname__Z
BM_compatibleZorderrr�dictZPATTERNrrrrrr!r%r'r)rr$rr
r
r
rr
s r
)�__doc__r"Zlib2to3rZlib2to3.fixer_utilrrrrrZBaseFixr
r
r
r
r�<module>
s
"

?>