-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestapp.py
More file actions
37 lines (28 loc) · 811 Bytes
/
testapp.py
File metadata and controls
37 lines (28 loc) · 811 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
36
37
from bytesized import ByteSized
def request_data(): # not needed and can be moved out of this interface. leaving it here for testing
return input("Please enter values.\n")
def data_to_str(data):
return f"""
Results
============
Bytes : {data['b']}
Pages : {data['p']}
Kilobytes : {data['k']}
Megabytes : {data['m']}
Gigabytes : {data['g']}
Terabytes : {data['t']}
Petabytes : {data['pb']}
"""
def main():
try:
formatted_data = request_data()
a = ByteSized(formatted_data)
print(data_to_str(a.results()))
except TypeError as e:
print(e)
print("This might be due to invalid input")
except UnboundLocalError as e:
print(e)
print("You may have started with a number instead of a bytesize")
if __name__ == "__main__":
main()