8000 Update to use Py3 print() (#1142) · nader-nagy/flutter-webrtc@5e2f393 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5e2f393

Browse files
authored
Update to use Py3 print() (flutter-webrtc#1142)
Make this usable in Python3. MacOS removed Python2
1 parent bf9edc8 commit 5e2f393

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

example/scripts/add-line.py

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

4+
from __future__ import print_function
45
import sys
56
import getopt
67
import re
@@ -21,21 +22,21 @@ def insertBefore(filename, pattern, text):
2122
with open(filename, 'r+') as fp:
2223
line_number = findLine(pattern, fp)
2324
if(line_number > 0):
24-
print 'Insert', text,'to line', line_number
25+
print('Insert', text,'to line', line_number)
2526
fp.seek(0)
2627
lines = fp.readlines()
2728
fp.seek(0)
2829
lines.insert(line_number - 1, text + '\n')
2930
fp.writelines(lines)
3031
return
31-
print 'pattern',text,'not found!'
32+
print('pattern',text,'not found!')
3233

3334
def replaceText(filename, pattern, text):
3435
with open(filename, 'r') as fp:
3536
lines = fp.read()
3637
fp.close()
3738
lines = (re.sub(pattern, text, lines))
38-
print 'Replace', pattern ,'to', text
39+
print('Replace', pattern ,'to', text)
3940
fp = open(filename, 'w')
4041
fp.write(lines)
4142
fp.close()
@@ -48,11 +49,11 @@ def main(argv):
4849
try:
4950
opts, args = getopt.getopt(argv, "hi:s:t:r")
5051
except getopt.GetoptError:
51-
print 'add-line.py -i <inputfile> -s <string> -t <text>'
52+
print('add-line.py -i <inputfile> -s <string> -t <text>')
5253
sys.exit(2)
5354
for opt, arg in opts:
5455
if opt == '-h':
55-
print 'add-line.py -i <inputfile> -s <string> -t <text>'
56+
print('add-line.py -i <inputfile> -s <string> -t <text>')
5657
sys.exit()
5758
elif opt in ("-i"):
5859
inputfile = arg

0 commit comments

Comments
 (0)
0