cs2tracker 2.1.14__py3-none-any.whl → 2.1.16__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cs2tracker might be problematic. Click here for more details.
- cs2tracker/_version.py +2 -2
- cs2tracker/app/__init__.py +0 -3
- cs2tracker/app/{application.py → app.py} +77 -45
- cs2tracker/app/editor_frame.py +223 -108
- cs2tracker/app/history_frame.py +61 -0
- cs2tracker/app/scraper_frame.py +13 -7
- cs2tracker/{util/validated_config.py → config.py} +97 -52
- cs2tracker/constants.py +20 -3
- cs2tracker/data/config.ini +24 -21
- cs2tracker/data/convert_inventory.js +108 -28
- cs2tracker/data/get_inventory.js +34 -13
- cs2tracker/logs.py +143 -0
- cs2tracker/main.py +3 -3
- cs2tracker/scraper/__init__.py +0 -9
- cs2tracker/scraper/background_task.py +80 -6
- cs2tracker/scraper/discord_notifier.py +34 -32
- cs2tracker/scraper/{parsers.py → parser.py} +35 -32
- cs2tracker/scraper/scraper.py +113 -83
- cs2tracker/util/__init__.py +0 -9
- cs2tracker/util/currency_conversion.py +84 -0
- cs2tracker/util/padded_console.py +5 -0
- cs2tracker/util/tkinter.py +55 -0
- {cs2tracker-2.1.14.dist-info → cs2tracker-2.1.16.dist-info}/METADATA +15 -16
- cs2tracker-2.1.16.dist-info/RECORD +31 -0
- cs2tracker/util/price_logs.py +0 -100
- cs2tracker-2.1.14.dist-info/RECORD +0 -28
- {cs2tracker-2.1.14.dist-info → cs2tracker-2.1.16.dist-info}/WHEEL +0 -0
- {cs2tracker-2.1.14.dist-info → cs2tracker-2.1.16.dist-info}/entry_points.txt +0 -0
- {cs2tracker-2.1.14.dist-info → cs2tracker-2.1.16.dist-info}/licenses/LICENSE +0 -0
- {cs2tracker-2.1.14.dist-info → cs2tracker-2.1.16.dist-info}/top_level.txt +0 -0
cs2tracker/util/price_logs.py
DELETED
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import csv
|
|
2
|
-
from datetime import datetime
|
|
3
|
-
|
|
4
|
-
from cs2tracker.constants import OUTPUT_FILE
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class PriceLogs:
|
|
8
|
-
@classmethod
|
|
9
|
-
def _append_latest_calculation(cls, date, usd_total, eur_total):
|
|
10
|
-
"""Append the first price calculation of the day."""
|
|
11
|
-
with open(OUTPUT_FILE, "a", newline="", encoding="utf-8") as price_logs:
|
|
12
|
-
price_logs_writer = csv.writer(price_logs)
|
|
13
|
-
price_logs_writer.writerow([date, f"{usd_total:.2f}$", f"{eur_total:.2f}€"])
|
|
14
|
-
|
|
15
|
-
@classmethod
|
|
16
|
-
def _replace_latest_calculation(cls, date, usd_total, eur_total):
|
|
17
|
-
"""Replace the last calculation of today with the most recent one of today."""
|
|
18
|
-
with open(OUTPUT_FILE, "r+", newline="", encoding="utf-8") as price_logs:
|
|
19
|
-
price_logs_reader = csv.reader(price_logs)
|
|
20
|
-
rows = list(price_logs_reader)
|
|
21
|
-
rows_without_today = rows[:-1]
|
|
22
|
-
price_logs.seek(0)
|
|
23
|
-
price_logs.truncate()
|
|
24
|
-
|
|
25
|
-
price_logs_writer = csv.writer(price_logs)
|
|
26
|
-
price_logs_writer.writerows(rows_without_today)
|
|
27
|
-
price_logs_writer.writerow([date, f"{usd_total:.2f}$", f"{eur_total:.2f}€"])
|
|
28
|
-
|
|
29
|
-
@classmethod
|
|
30
|
-
def save(cls, usd_total, eur_total):
|
|
31
|
-
"""
|
|
32
|
-
Save the current date and total prices in USD and EUR to a CSV file.
|
|
33
|
-
|
|
34
|
-
This will append a new entry to the output file if no entry has been made for
|
|
35
|
-
today.
|
|
36
|
-
|
|
37
|
-
:param usd_total: The total price in USD to save.
|
|
38
|
-
:param eur_total: The total price in EUR to save.
|
|
39
|
-
:raises FileNotFoundError: If the output file does not exist.
|
|
40
|
-
:raises IOError: If there is an error writing to the output file.
|
|
41
|
-
"""
|
|
42
|
-
with open(OUTPUT_FILE, "r", encoding="utf-8") as price_logs:
|
|
43
|
-
price_logs_reader = csv.reader(price_logs)
|
|
44
|
-
rows = list(price_logs_reader)
|
|
45
|
-
last_log_date, _, _ = rows[-1] if rows else ("", "", "")
|
|
46
|
-
|
|
47
|
-
today = datetime.now().strftime("%Y-%m-%d")
|
|
48
|
-
if last_log_date != today:
|
|
49
|
-
cls._append_latest_calculation(today, usd_total, eur_total)
|
|
50
|
-
else:
|
|
51
|
-
cls._replace_latest_calculation(today, usd_total, eur_total)
|
|
52
|
-
|
|
53
|
-
@classmethod
|
|
54
|
-
def read(cls):
|
|
55
|
-
"""
|
|
56
|
-
Parse the output file to extract dates, dollar prices, and euro prices. This
|
|
57
|
-
data is used for drawing the plot of past prices.
|
|
58
|
-
|
|
59
|
-
:return: A tuple containing three lists: dates, dollar prices, and euro prices.
|
|
60
|
-
:raises FileNotFoundError: If the output file does not exist.
|
|
61
|
-
:raises IOError: If there is an error reading the output file.
|
|
62
|
-
"""
|
|
63
|
-
dates, usd_prices, eur_prices = [], [], []
|
|
64
|
-
with open(OUTPUT_FILE, "r", encoding="utf-8") as price_logs:
|
|
65
|
-
price_logs_reader = csv.reader(price_logs)
|
|
66
|
-
for row in price_logs_reader:
|
|
67
|
-
date, price_usd, price_eur = row
|
|
68
|
-
date = datetime.strptime(date, "%Y-%m-%d")
|
|
69
|
-
price_usd = float(price_usd.rstrip("$"))
|
|
70
|
-
price_eur = float(price_eur.rstrip("€"))
|
|
71
|
-
|
|
72
|
-
dates.append(date)
|
|
73
|
-
usd_prices.append(price_usd)
|
|
74
|
-
eur_prices.append(price_eur)
|
|
75
|
-
|
|
76
|
-
return dates, usd_prices, eur_prices
|
|
77
|
-
|
|
78
|
-
@classmethod
|
|
79
|
-
def validate_file(cls, log_file_path):
|
|
80
|
-
"""
|
|
81
|
-
Ensures that the provided price log file has the right format. This should be
|
|
82
|
-
used before importing a price log file to ensure it is valid.
|
|
83
|
-
|
|
84
|
-
:param log_file_path: The path to the price log file to validate.
|
|
85
|
-
:return: True if the price log file is valid, False otherwise.
|
|
86
|
-
"""
|
|
87
|
-
try:
|
|
88
|
-
with open(log_file_path, "r", encoding="utf-8") as price_logs:
|
|
89
|
-
price_logs_reader = csv.reader(price_logs)
|
|
90
|
-
for row in price_logs_reader:
|
|
91
|
-
date_str, price_usd, price_eur = row
|
|
92
|
-
datetime.strptime(date_str, "%Y-%m-%d")
|
|
93
|
-
float(price_usd.rstrip("$"))
|
|
94
|
-
float(price_eur.rstrip("€"))
|
|
95
|
-
except (FileNotFoundError, IOError, ValueError, TypeError):
|
|
96
|
-
return False
|
|
97
|
-
except Exception:
|
|
98
|
-
return False
|
|
99
|
-
|
|
100
|
-
return True
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
cs2tracker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
cs2tracker/__main__.py,sha256=Ub--oSMv48YzfWF1CZqYlkn1-HvZ7Bhxoc7urn1oY6o,249
|
|
3
|
-
cs2tracker/_version.py,sha256=80wtCyj9QUrrEVvuEW7o-ILwCKz10sXaQFnSq4DOKBE,513
|
|
4
|
-
cs2tracker/constants.py,sha256=9E1CPVEohDmV_F2PLLrPRmtYAHHVDimbUFfohhjci1c,6742
|
|
5
|
-
cs2tracker/main.py,sha256=_Y8be0bVDaoO4SE-TZjJ0wpXjvXDYF3VPKC4f32nZc0,1019
|
|
6
|
-
cs2tracker/app/__init__.py,sha256=uqAxdDzoR2-2IrDc1riIU3Pi9vLEDwr68eg93-0RFmM,105
|
|
7
|
-
cs2tracker/app/application.py,sha256=wjUFt5RzRZ8gRqprtPaCTtHW_cEWS3DzmcdRz48vmFg,9135
|
|
8
|
-
cs2tracker/app/editor_frame.py,sha256=zbNaZOBhFCWjJrl-kCgdbBPafeRgEcYG31tDgMaZ3_s,21313
|
|
9
|
-
cs2tracker/app/scraper_frame.py,sha256=9m5tQFhPGCqWWtkgSG_XuH9ELj-km83lU93tSBqndNA,4007
|
|
10
|
-
cs2tracker/data/config.ini,sha256=oLm6Ggfqjr8coDZE4NAMVomZZDJqMia0VxNO3wCzHsQ,15059
|
|
11
|
-
cs2tracker/data/convert_inventory.js,sha256=5bEDfe9Rf2wYC4dIlmvjhbslfnuKuBBNjuTk67jEV9Q,5370
|
|
12
|
-
cs2tracker/data/get_inventory.js,sha256=YL0RJV1j2K0J20mRZVXSakwU8fpRtjyMLrAYFl0-rsM,5793
|
|
13
|
-
cs2tracker/data/output.csv,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
|
-
cs2tracker/scraper/__init__.py,sha256=kfUB9yfshSche92ZvTqQQYBkVqujRez46djPoa9u0YU,335
|
|
15
|
-
cs2tracker/scraper/background_task.py,sha256=1_lKnFWn9wuABpru58JdQbfDHjL0Up-7h6Nlcc4TsZ4,3671
|
|
16
|
-
cs2tracker/scraper/discord_notifier.py,sha256=-PdTRAtzMHTjDH17zguI0LKB7INITEohx0da0fWRdKI,2962
|
|
17
|
-
cs2tracker/scraper/parsers.py,sha256=BcCRU39RXtkpXOZouh2LLTDlCOJAFAJmyaQVVwK1i4A,6897
|
|
18
|
-
cs2tracker/scraper/scraper.py,sha256=sotDjZMrMxkM_bCOhPm9S-Pq82-pJp-8RPNcxtY9cPs,10462
|
|
19
|
-
cs2tracker/util/__init__.py,sha256=Pgltyrkotd5ijU-srmY5vaFP7gzz9itSAl2LfS-D7-E,322
|
|
20
|
-
cs2tracker/util/padded_console.py,sha256=u8SNbjvR_YyePhpiqREt4Kh4NiDI5NAPCPL5toqh8dg,1622
|
|
21
|
-
cs2tracker/util/price_logs.py,sha256=JuZ2ptDtxA-NzKjpG_4q0eeOr1IaUvVah-Qth6GrDDU,4165
|
|
22
|
-
cs2tracker/util/validated_config.py,sha256=ZsUTaahs08HBEoCM2XUzAHqjKeaeU3XzBNhGxr1kEfg,8740
|
|
23
|
-
cs2tracker-2.1.14.dist-info/licenses/LICENSE,sha256=doPNswWMPXbkhplb9cnZLwJoqqS72pJPhkSib8kIF08,19122
|
|
24
|
-
cs2tracker-2.1.14.dist-info/METADATA,sha256=hehgmIANx4SmR2lJOlurlsV54ERx9TVg3fi80No46kM,5782
|
|
25
|
-
cs2tracker-2.1.14.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
26
|
-
cs2tracker-2.1.14.dist-info/entry_points.txt,sha256=K8IwDIkg8QztSB9g9c89B9jR_2pG4QyJGrNs4z5RcZw,63
|
|
27
|
-
cs2tracker-2.1.14.dist-info/top_level.txt,sha256=2HB4xDDOxaU5BDc_yvdi9UlYLgL768n8aR-hRhFM6VQ,11
|
|
28
|
-
cs2tracker-2.1.14.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|