Skip to content

Commit 5ab07d2

Browse files
Update add-line to python3 (#466)
Co-authored-by: Victor Uvarov <[email protected]>
1 parent 8d00b5d commit 5ab07d2

File tree

2 files changed

+38
-40
lines changed

2 files changed

+38
-40
lines changed

example/scripts/add-line.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/python
1+
#!/usr/bin/python3
22
# -*- coding: UTF-8 -*-
33

44
import sys
@@ -21,24 +21,22 @@ def insertBefore(filename, pattern, text):
2121
with open(filename, 'r+') as fp:
2222
line_number = findLine(pattern, fp)
2323
if(line_number > 0):
24-
print 'Insert', text,'to line', line_number
24+
print('Insert', text,'to line', line_number)
2525
fp.seek(0)
2626
lines = fp.readlines()
2727
fp.seek(0)
2828
lines.insert(line_number - 1, text + '\n')
2929
fp.writelines(lines)
3030
return
31-
print 'pattern',text,'not found!'
31+
print('pattern',text,'not found!')
3232

3333
def replaceText(filename, pattern, text):
3434
with open(filename, 'r') as fp:
3535
lines = fp.read()
36-
fp.close()
37-
lines = (re.sub(pattern, text, lines))
38-
print 'Replace', pattern ,'to', text
39-
fp = open(filename, 'w')
36+
lines = re.sub(pattern, text, lines)
37+
print('Replace', pattern ,'to', text)
38+
with open(filename, 'w') as fp:
4039
fp.write(lines)
41-
fp.close()
4240

4341
def main(argv):
4442
inputfile = ''
@@ -48,11 +46,11 @@ def main(argv):
4846
try:
4947
opts, args = getopt.getopt(argv, "hi:s:t:r")
5048
except getopt.GetoptError:
51-
print 'add-line.py -i <inputfile> -s <string> -t <text>'
49+
print('add-line.py -i <inputfile> -s <string> -t <text>')
5250
sys.exit(2)
5351
for opt, arg in opts:
5452
if opt == '-h':
55-
print 'add-line.py -i <inputfile> -s <string> -t <text>'
53+
print('add-line.py -i <inputfile> -s <string> -t <text>')
5654
sys.exit()
5755
elif opt in ("-i"):
5856
inputfile = arg

example/scripts/project_tools.sh

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,44 @@ function add_permission_label() {
2929
echo ""
3030
echo "Add permission labels to iOS."
3131
echo ""
32-
python add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <key>NSCameraUsageDescription</key>'
33-
python add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <string>$(PRODUCT_NAME) Camera Usage!</string>'
34-
python add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <key>NSMicrophoneUsageDescription</key>'
35-
python add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <string>$(PRODUCT_NAME) Microphone Usage!</string>'
36-
python add-line.py -i ../ios/Podfile -s "# platform :ios, '9.0'" -t "platform :ios, '10.0'" -r
32+
python3 add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <key>NSCameraUsageDescription</key>'
33+
python3 add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <string>$(PRODUCT_NAME) Camera Usage!</string>'
34+
python3 add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <key>NSMicrophoneUsageDescription</key>'
35+
python3 add-line.py -i ../ios/Runner/Info.plist -s '<key>UILaunchStoryboardName</key>' -t ' <string>$(PRODUCT_NAME) Microphone Usage!</string>'
36+
python3 add-line.py -i ../ios/Podfile -s "# platform :ios, '9.0'" -t "platform :ios, '10.0'" -r
3737
echo ""
3838
echo "Add permission labels to AndroidManifest.xml."
3939
echo ""
40-
python add-line.py -i ../android/app/build.gradle -s 'minSdkVersion 16' -t 'minSdkVersion 21' -r
41-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.CAMERA" />'
42-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.RECORD_AUDIO" />'
43-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.WAKE_LOCK" />'
44-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />'
45-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />'
46-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />'
47-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />'
48-
python add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />'
40+
python3 add-line.py -i ../android/app/build.gradle -s 'minSdkVersion 16' -t 'minSdkVersion 21' -r
41+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.CAMERA" />'
42+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.RECORD_AUDIO" />'
43+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.WAKE_LOCK" />'
44+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />'
45+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />'
46+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />'
47+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />'
48+
python3 add-line.py -i ../android/app/src/main/AndroidManifest.xml -s "<application" -t ' <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />'
4949
echo ""
5050
echo "Add permission labels to macOS."
5151
echo ""
52-
python add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <key>NSCameraUsageDescription</key>'
53-
python add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <string>$(PRODUCT_NAME) Camera Usage!</string>'
54-
python add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <key>NSMicrophoneUsageDescription</key>'
55-
python add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <string>$(PRODUCT_NAME) Microphone Usage!</string>'
52+
python3 add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <key>NSCameraUsageDescription</key>'
53+
python3 add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <string>$(PRODUCT_NAME) Camera Usage!</string>'
54+
python3 add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <key>NSMicrophoneUsageDescription</key>'
55+
python3 add-line.py -i ../macos/Runner/Info.plist -s '<key>CFBundleShortVersionString</key>' -t ' <string>$(PRODUCT_NAME) Microphone Usage!</string>'
5656

57-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.device.camera</key>'
58-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
59-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.device.microphone</key>'
60-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
61-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.network.client</key>'
62-
python add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
57+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.device.camera</key>'
58+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
59+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.device.microphone</key>'
60+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
61+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <key>com.apple.security.network.client</key>'
62+
python3 add-line.py -i ../macos/Runner/DebugProfile.entitlements -s '</dict>' -t ' <true/>'
6363

64-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.device.camera</key>'
65-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
66-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.device.microphone</key>'
67-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
68-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.network.client</key>'
69-
python add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
64+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.device.camera</key>'
65+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
66+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.device.microphone</key>'
67+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
68+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <key>com.apple.security.network.client</key>'
69+
python3 add-line.py -i ../macos/Runner/Release.entitlements -s '</dict>' -t ' <true/>'
7070
}
7171

7272
if [ "$CMD" == "create" ];

0 commit comments

Comments
 (0)