-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.py
30 lines (23 loc) · 845 Bytes
/
utils.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
def get_price(shop_name, item):
price_string = item['price']
price = int(price_string) if price_string.isdigit() else 0
# price is invalid / 0
if price == 0:
log('', shop_name, f"Skipping {item['material_id']} because price {price_string} is not a number")
return price
def round_sell_price(price):
return round(price, 2) if price < 0.8 else round(price)
def log(updater='', shop=None, message=None):
"""
Print a message to console
:param updater: the updater implementation name, eg 'essentials'
:type updater: str
:param shop: the shop name, used for the message prefix
:type shop: str
:param message: the message to be printed
:type message: str
"""
if updater == '':
print(f"[{shop}] {message}")
else:
print(f"[{shop}] ({updater}) {message}")