-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (36 loc) · 1.03 KB
/
main.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
41
42
43
44
45
46
from container import Container
from sys import argv
# Main method: program starting point.
def main(args):
try:
fin = open(args[0], 'r')
except:
print(f'File {args[0]} is unavailable to read from!')
return
try:
fout = open(args[1], 'w+')
except:
print(f'File {args[1]} is unavailable to write to!')
return
cont = Container.create(fin)
if cont is None:
print('Bad input file!')
fout.write('Bad input file!')
return
fout.write('Container before changes:\n')
cont.write_to_file(fout)
fout.write('\n')
cont.remove_lesser_than_average()
fout.write('Container after changes:\n')
cont.write_to_file(fout)
fout.write('\n')
try:
fin.close()
fout.close()
except:
pass
if __name__ == '__main__':
if len(argv) != 3:
print("Incorrect arguments format!\n", "Correct:\n", "main.py in_file out_file\n", sep='')
else:
main(argv[1:])