-
Notifications
You must be signed in to change notification settings - Fork 2
/
toAndroidX.py
40 lines (32 loc) · 1.17 KB
/
toAndroidX.py
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
39
40
# by lei
# coding: utf-8
import os
import time
# 需要修改的目录。**************8 (need to change dir)
# 需要自己写 nodeModules 目录 (nodeModules direction)
nodeModulesDir = './node_modules/'
# 需要自己写android目录 (android direction)
androidDir = './android/'
# *************
filePath = "./androidx-class-mapping.csv"
readFile = open(filePath, "r")
buf = readFile.read()
readFile.close()
toMap = {}
arr1 = buf.split('\n')
for v in arr1:
print(v)
arr2 = v.split(',')
if (len(arr2) >= 2) :
supportClass = arr2[0]
androidXClass = arr2[1]
toMap[supportClass] = androidXClass
print(toMap)
# toMap = {'android.support.v4.content.FileProvider': 'androidx.core.content.FileProvider'}
for k in toMap:
print(k)
os.system('grep -rl \'' + k + '\' --include "*.java" ' + nodeModulesDir + ' | xargs sed -i "" "s/' + k + '/' + toMap[k] + '/g"')
os.system('grep -rl \'' + k + '\' --include "*.xml" ' + nodeModulesDir + ' | xargs sed -i "" "s/' + k + '/' + toMap[k] + '/g"')
for k in toMap:
os.system('grep -rl \'' + k + '\' --include "*.java" ' + androidDir + ' | xargs sed -i "" "s/' + k + '/' + toMap[k] + '/g"')
print('over')