-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMIPS-Runner.py
50 lines (40 loc) · 2.92 KB
/
MIPS-Runner.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
47
48
49
50
#!/usr/bin/env python3
import sys
import time
# Title Sequence
print("███╗ ███╗██╗██████╗ ███████╗ ██████╗ ██╗ ██╗███╗ ██╗███╗ ██╗███████╗██████╗ \n████╗ ████║██║██╔══██╗██╔════╝ ██╔══██╗██║ ██║████╗ ██║████╗ ██║██╔════╝██╔══██╗\n██╔████╔██║██║██████╔╝███████╗█████╗██████╔╝██║ ██║██╔██╗ ██║██╔██╗ ██║█████╗ ██████╔╝\n██║╚██╔╝██║██║██╔═══╝ ╚════██║╚════╝██╔══██╗██║ ██║██║╚██╗██║██║╚██╗██║██╔══╝ ██╔══██╗\n██║ ╚═╝ ██║██║██║ ███████║ ██║ ██║╚██████╔╝██║ ╚████║██║ ╚████║███████╗██║ ██║\n╚═╝ ╚═╝╚═╝╚═╝ ╚══════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═╝")
def printProgressBar (iteration, total, prefix = '', suffix = '', decimals = 1, length = 100, fill = '█', printEnd = "\r"):
percent = ("{0:." + str(decimals) + "f}").format(100 * (iteration / float(total)))
filledLength = int(length * iteration // total)
bar = fill * filledLength + '-' * (length - filledLength)
print(f'\r{prefix} |{bar}| {percent}% {suffix}', end = printEnd)
# Print New Line on Complete
if iteration == total:
print()
if len(sys.argv) > 1:
importFile = sys.argv[1]
exportFile = sys.argv[1] + ".converted"
else:
importFile = input("Filename: ")
exportFile = importFile + ".converted"
items = list(range(0, 10))
l = len(items)
# So you want to give the code a bit of a looksy? The progress bar literally does nothing. :)
# They suggest that if you have a progress bar in your applications it makes the user happy.
printProgressBar(0, l, prefix = 'Progress:', suffix = 'Complete', length = 50)
for i, item in enumerate(items):
time.sleep(0.1)
printProgressBar(i + 1, l, prefix = 'Progress:', suffix = 'Complete', length = 50)
f = open(importFile,"r")
o = open(exportFile, "w")
for line in f.readlines():
try:
if line.strip() == "":
continue
o.write('mipsInst.assembler.addInstruction("' + line.replace("\n","") + '")\n')
except:
print("Beep Boop error occured with line:")
print(line)
continue
print()
print("File output at: " + exportFile)