Yf
@ sm d Z d d l Z d d l m Z d d l m Z m Z m Z m Z d d Z Gd d d e j
Z d S) 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)CallNameStringtouch_importc s f d d } | S)Nc s
| _ | S)N)
invocation)f)s ?/opt/alt/python35/lib64/python3.5/lib2to3/fixes/fix_operator.pydec s zinvocation..decr
)r r r
)r r r s r c @ s e Z d Z d Z d Z d Z d Z d e d e d e Z d d Z e
d
d d Z e
d
d d Z e
d d d Z
e
d d d Z e
d d d Z e
d d d Z e
d d d Z d d Z d! d" Z d# d$ Z d% 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 > >
methodsobjc C s/ | j | | } | d k r+ | | | Sd S)N)
_check_method)selfnoderesultsmethodr
r
r transform+ s zFixOperator.transformzoperator.contains(%s)c C s | j | | d S)Ncontains)_handle_rename)r r r r
r
r _sequenceIncludes0 s zFixOperator._sequenceIncludeszhasattr(%s, '__call__')c C sG | d } | j t d t d g } t t d | d | j S)Nr z, z
'__call__'hasattrprefix)cloner r r r )r r r r argsr
r
r _isCallable4 s
!zFixOperator._isCallablezoperator.mul(%s)c C s | j | | d S)Nmul)r )r r r r
r
r _repeat: s zFixOperator._repeatzoperator.imul(%s)c C s | j | | d S)Nimul)r )r r r r
r
r _irepeat> s zFixOperator._irepeatz$isinstance(%s, collections.Sequence)c C s | j | | d d S)NcollectionsSequence)_handle_type2abc)r r r r
r
r _isSequenceTypeB s zFixOperator._isSequenceTypez#isinstance(%s, collections.Mapping)c C s | j | | d d S)Nr" Mapping)r$ )r r r r
r
r _isMappingTypeF s zFixOperator._isMappingTypezisinstance(%s, numbers.Number)c C s | j | | d d S)NZnumbersNumber)r$ )r r r r
r
r
_isNumberTypeJ s zFixOperator._isNumberTypec C s% | d d } | | _ | j d S)Nr r )valueZchanged)r r r namer r
r
r r N s zFixOperator._handle_renamec C sa t d | | | d } | j t d d j | | g g } t t d | d | j S)Nr z, .
isinstancer )r r r joinr r r )r r r moduleabcr r r
r
r r$ S s
+zFixOperator._handle_type2abcc C sx t | d | d d j } t | t j rt d | k r@ | St | d f } | j | } | j | d | d S)N_r r r/ r zYou should use '%s' here.)getattrr* r- r" Callablestrr Zwarning)r r r r subZinvocation_strr
r
r r Y s
zFixOperator._check_methodN)__name__
__module____qualname__Z
BM_compatibleorderr r dictZPATTERNr r r r r r! r% r' r) r r$ r r
r
r
r r
s r
)__doc__r" Zlib2to3r Zlib2to3.fixer_utilr r r r r ZBaseFixr
r
r
r
r
s
"