-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.py
74 lines (62 loc) · 2.47 KB
/
ui.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import os
from datetime import datetime
def clr():
os.system('cls' if os.name == 'nt' else 'clear')
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)
if iteration == total:
print()
def getSortPreference():
print("Sort by:")
print("1. Total price")
print("2. Average price")
print("3. Latest trade date")
print("4. Seller ID")
sort_choice = input("Enter your choice >>> ")
if sort_choice in ['1', '2', '3']:
clr()
print('Sorting method:')
if sort_choice in ['1', '2']:
print('1. Highest first')
print('2. Lowest first')
else: # sort_choice == '3'
print('1. Oldest first')
print('2. Newest first')
order_choice = input("Enter your choice >>> ")
return sort_choice, order_choice
return sort_choice, None
def displaySummary(summary, currency, convert_currency_func):
now = datetime.now().astimezone()
for i in summary:
time_diff = now - i['latest_trade_date']
days_ago = time_diff.days
total_converted = round(convert_currency_func(float(i['total']), currency), 2)
avg_converted = round(convert_currency_func(float(i['average']), currency), 2)
print(f"Seller >>> {i['seller']} | Total >>> {total_converted} {currency} | Average item price >>> {avg_converted} {currency} | Last Trade >>> {days_ago} days ago")
return input("Press any key to continue...")
def getCurrencyChoice():
print("Select a currency:")
print("1. USD")
print("2. EUR")
print("3. GBP")
print("4. CNY")
print("5. PLN")
return input("Enter your choice >>> ")
def displayMenu(current_currency):
clr()
print("Select an option:")
print("1. Show summary")
print("2. Refresh data")
print("3. Change session token")
print(f"4. Change currency | Currently set to {current_currency}")
print("5. Exit")
return input("Enter your choice >>> ")
def getNewToken():
return input("Enter your CSFloat session token >>> ")
def showMessage(message, wait_for_key=True):
print(message)
if wait_for_key:
input("Press any key to continue...")