1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import sys
from bowler import Query
from bowler.imr import FunctionArgument, FunctionSpec
from fissix.fixer_util import Name
def addActivityDefaultValue(node, capture, filename):
if 'PaypalService.py' in filename:
# XXX moreorless.patch.PatchException: Failed to apply with offset at 103
return False
spec = FunctionSpec.build(node, capture)
for arg in spec.arguments:
if arg.name == 'activity':
return False
if arg.star:
print(f"Warning: skipping because ** used: {filename}:{arg.star.lineno}")
return False
value = Name("'SQLDict'")
prefix = None
# try to keep indentation for multi lines arguments
if spec.arguments and spec.arguments[-1].prefix:
prefix = spec.arguments[0].prefix
fa = FunctionArgument('activity', value, '')
spec.arguments.insert(0, fa)
spec.arguments[0].prefix = prefix
spec.explode()
return True
(
Query(sys.argv[1], python_version=2)
.select_method('activate')
.is_call()
.filter(addActivityDefaultValue)
.write()
)