-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfastio.py
More file actions
35 lines (28 loc) · 684 Bytes
/
fastio.py
File metadata and controls
35 lines (28 loc) · 684 Bytes
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
import converter
import sys
# if you do not want to print the code in terminal set
# the variable to false
printInTerminal = True
# if you do not want to print the code in a new file
# set the variable below to false
printInFile = True
fileName = ''
if len(sys.argv) == 2:
fileName = sys.argv[1]
else:
fileName = input('Type the name of the file\n')
while True:
try:
code = open(fileName, "r").read()
break
except:
fileName = input('File not found, try again\n')
code = converter.convertToFastIO(code)
if printInFile:
r = fileName.split('/')
newName = 'FastIO-' + r[-1]
file = open(newName, 'w')
file.write(code)
file.close()
if printInTerminal:
print (code)