cs2tracker 2.1.13__py3-none-any.whl → 2.1.14__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/application.py +72 -76
- cs2tracker/app/editor_frame.py +208 -127
- cs2tracker/app/scraper_frame.py +27 -10
- cs2tracker/constants.py +58 -321
- cs2tracker/data/config.ini +153 -153
- cs2tracker/data/get_inventory.js +64 -21
- cs2tracker/main.py +1 -16
- cs2tracker/scraper/parsers.py +192 -0
- cs2tracker/scraper/scraper.py +102 -212
- cs2tracker/util/padded_console.py +19 -0
- cs2tracker/util/validated_config.py +72 -18
- {cs2tracker-2.1.13.dist-info → cs2tracker-2.1.14.dist-info}/METADATA +3 -2
- cs2tracker-2.1.14.dist-info/RECORD +28 -0
- cs2tracker-2.1.13.dist-info/RECORD +0 -27
- {cs2tracker-2.1.13.dist-info → cs2tracker-2.1.14.dist-info}/WHEEL +0 -0
- {cs2tracker-2.1.13.dist-info → cs2tracker-2.1.14.dist-info}/entry_points.txt +0 -0
- {cs2tracker-2.1.13.dist-info → cs2tracker-2.1.14.dist-info}/licenses/LICENSE +0 -0
- {cs2tracker-2.1.13.dist-info → cs2tracker-2.1.14.dist-info}/top_level.txt +0 -0
cs2tracker/_version.py
CHANGED
cs2tracker/app/application.py
CHANGED
|
@@ -34,46 +34,80 @@ config = get_config()
|
|
|
34
34
|
class Application:
|
|
35
35
|
def __init__(self):
|
|
36
36
|
self.scraper = Scraper()
|
|
37
|
-
self.application_window = None
|
|
38
37
|
|
|
39
38
|
def run(self):
|
|
40
|
-
"""Run the main application window
|
|
41
|
-
|
|
42
|
-
"""
|
|
43
|
-
self.application_window = self._configure_window()
|
|
39
|
+
"""Run the main application window."""
|
|
40
|
+
window = self._configure_window()
|
|
44
41
|
|
|
45
42
|
if DARK_THEME:
|
|
46
43
|
sv_ttk.use_dark_theme()
|
|
47
44
|
else:
|
|
48
45
|
sv_ttk.use_light_theme()
|
|
49
46
|
|
|
50
|
-
|
|
47
|
+
window.mainloop()
|
|
48
|
+
|
|
49
|
+
def _configure_window(self):
|
|
50
|
+
"""Configure the main application window."""
|
|
51
|
+
window = tk.Tk()
|
|
52
|
+
window.title(APPLICATION_NAME)
|
|
53
|
+
window.geometry(WINDOW_SIZE)
|
|
54
|
+
|
|
55
|
+
if OS == OSType.WINDOWS:
|
|
56
|
+
app_id = "cs2tracker.unique.id"
|
|
57
|
+
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
|
|
58
|
+
|
|
59
|
+
icon = tk.PhotoImage(file=ICON_FILE)
|
|
60
|
+
window.wm_iconphoto(True, icon)
|
|
61
|
+
|
|
62
|
+
main_frame = MainFrame(window, self.scraper)
|
|
63
|
+
main_frame.pack(expand=True, fill="both")
|
|
64
|
+
|
|
65
|
+
return window
|
|
51
66
|
|
|
52
|
-
|
|
67
|
+
|
|
68
|
+
class MainFrame(ttk.Frame):
|
|
69
|
+
# pylint: disable=too-many-instance-attributes,attribute-defined-outside-init
|
|
70
|
+
def __init__(self, parent, scraper):
|
|
71
|
+
super().__init__(parent, padding=15)
|
|
72
|
+
self.parent = parent
|
|
73
|
+
self.scraper = scraper
|
|
74
|
+
self._add_widgets()
|
|
75
|
+
|
|
76
|
+
def _add_widgets(self):
|
|
77
|
+
"""Add widgets to the main frame."""
|
|
78
|
+
self.columnconfigure(0, weight=1)
|
|
79
|
+
self.columnconfigure(1, weight=1)
|
|
80
|
+
self.rowconfigure(0, weight=1)
|
|
81
|
+
|
|
82
|
+
self._configure_button_frame()
|
|
83
|
+
self.button_frame.grid(row=0, column=0, padx=10, pady=(7, 20), sticky="nsew")
|
|
84
|
+
self._configure_checkbox_frame()
|
|
85
|
+
self.checkbox_frame.grid(row=0, column=1, padx=10, pady=(0, 20), sticky="nsew")
|
|
86
|
+
|
|
87
|
+
def _add_button(self, text, command, row):
|
|
53
88
|
"""Create and style a button for the button frame."""
|
|
54
89
|
grid_pos = {"row": row, "column": 0, "sticky": "ew", "padx": 10, "pady": 10}
|
|
55
|
-
button = ttk.Button(
|
|
90
|
+
button = ttk.Button(self.button_frame, text=text, command=command)
|
|
56
91
|
button.grid(**grid_pos)
|
|
57
92
|
|
|
58
|
-
def _configure_button_frame(self
|
|
93
|
+
def _configure_button_frame(self):
|
|
59
94
|
"""Configure the button frame of the application main frame."""
|
|
60
|
-
button_frame = ttk.Frame(
|
|
61
|
-
button_frame.columnconfigure(0, weight=1)
|
|
62
|
-
button_frame.grid(row=0, column=0, padx=10, pady=(7, 20), sticky="nsew")
|
|
95
|
+
self.button_frame = ttk.Frame(self, style="Card.TFrame", padding=15)
|
|
96
|
+
self.button_frame.columnconfigure(0, weight=1)
|
|
63
97
|
|
|
64
|
-
self._add_button(
|
|
65
|
-
self._add_button(
|
|
66
|
-
self._add_button(
|
|
67
|
-
self._add_button(
|
|
68
|
-
self._add_button(
|
|
98
|
+
self._add_button("Run!", self.scrape_prices, 0)
|
|
99
|
+
self._add_button("Edit Config", self._edit_config, 1)
|
|
100
|
+
self._add_button("Show History", self._draw_plot, 2)
|
|
101
|
+
self._add_button("Export History", self._export_log_file, 3)
|
|
102
|
+
self._add_button("Import History", self._import_log_file, 4)
|
|
69
103
|
|
|
70
104
|
def _add_checkbox(
|
|
71
|
-
self,
|
|
72
|
-
): # pylint: disable=too-many-arguments,too-many-positional-arguments
|
|
105
|
+
self, text, variable, command, row
|
|
106
|
+
): # pylint: disable=too-many-arguments,too-many-positional-arguments,attribute-defined-outside-init
|
|
73
107
|
"""Create and style a checkbox for the checkbox frame."""
|
|
74
108
|
grid_pos = {"row": row, "column": 0, "sticky": "w", "padx": (10, 0), "pady": 5}
|
|
75
109
|
checkbox = ttk.Checkbutton(
|
|
76
|
-
|
|
110
|
+
self.checkbox_frame,
|
|
77
111
|
text=text,
|
|
78
112
|
variable=variable,
|
|
79
113
|
command=command,
|
|
@@ -81,90 +115,50 @@ class Application:
|
|
|
81
115
|
)
|
|
82
116
|
checkbox.grid(**grid_pos)
|
|
83
117
|
|
|
84
|
-
def _configure_checkbox_frame(self
|
|
118
|
+
def _configure_checkbox_frame(self):
|
|
85
119
|
"""Configure the checkbox frame for background tasks and settings."""
|
|
86
|
-
checkbox_frame = ttk.LabelFrame(
|
|
87
|
-
checkbox_frame.grid(row=0, column=1, padx=10, pady=(0, 20), sticky="nsew")
|
|
120
|
+
self.checkbox_frame = ttk.LabelFrame(self, text="Settings", padding=15)
|
|
88
121
|
|
|
89
|
-
background_checkbox_value = tk.BooleanVar(value=BackgroundTask.identify())
|
|
122
|
+
self.background_checkbox_value = tk.BooleanVar(value=BackgroundTask.identify())
|
|
90
123
|
self._add_checkbox(
|
|
91
|
-
checkbox_frame,
|
|
92
124
|
"Background Task",
|
|
93
|
-
background_checkbox_value,
|
|
94
|
-
lambda: self._toggle_background_task(background_checkbox_value.get()),
|
|
125
|
+
self.background_checkbox_value,
|
|
126
|
+
lambda: self._toggle_background_task(self.background_checkbox_value.get()),
|
|
95
127
|
0,
|
|
96
128
|
)
|
|
97
129
|
|
|
98
|
-
discord_webhook_checkbox_value = tk.BooleanVar(
|
|
130
|
+
self.discord_webhook_checkbox_value = tk.BooleanVar(
|
|
99
131
|
value=config.getboolean("App Settings", "discord_notifications", fallback=False)
|
|
100
132
|
)
|
|
101
133
|
self._add_checkbox(
|
|
102
|
-
checkbox_frame,
|
|
103
134
|
"Discord Notifications",
|
|
104
|
-
discord_webhook_checkbox_value,
|
|
105
|
-
lambda: discord_webhook_checkbox_value.set(
|
|
106
|
-
self._toggle_discord_webhook(discord_webhook_checkbox_value.get())
|
|
135
|
+
self.discord_webhook_checkbox_value,
|
|
136
|
+
lambda: self.discord_webhook_checkbox_value.set(
|
|
137
|
+
self._toggle_discord_webhook(self.discord_webhook_checkbox_value.get())
|
|
107
138
|
),
|
|
108
139
|
1,
|
|
109
140
|
)
|
|
110
141
|
|
|
111
|
-
use_proxy_checkbox_value = tk.BooleanVar(
|
|
142
|
+
self.use_proxy_checkbox_value = tk.BooleanVar(
|
|
112
143
|
value=config.getboolean("App Settings", "use_proxy", fallback=False)
|
|
113
144
|
)
|
|
114
145
|
self._add_checkbox(
|
|
115
|
-
checkbox_frame,
|
|
116
146
|
"Proxy Requests",
|
|
117
|
-
use_proxy_checkbox_value,
|
|
118
|
-
lambda: use_proxy_checkbox_value.set(
|
|
119
|
-
self._toggle_use_proxy(use_proxy_checkbox_value.get())
|
|
147
|
+
self.use_proxy_checkbox_value,
|
|
148
|
+
lambda: self.use_proxy_checkbox_value.set(
|
|
149
|
+
self._toggle_use_proxy(self.use_proxy_checkbox_value.get())
|
|
120
150
|
),
|
|
121
151
|
2,
|
|
122
152
|
)
|
|
123
153
|
|
|
124
|
-
# pylint: disable=attribute-defined-outside-init
|
|
125
154
|
self.dark_theme_checkbox_value = tk.BooleanVar(value=DARK_THEME)
|
|
126
|
-
self._add_checkbox(
|
|
127
|
-
checkbox_frame, "Dark Theme", self.dark_theme_checkbox_value, sv_ttk.toggle_theme, 3
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
def _configure_main_frame(self, window):
|
|
131
|
-
"""Configure the main frame of the application window with buttons and
|
|
132
|
-
checkboxes.
|
|
133
|
-
"""
|
|
134
|
-
main_frame = ttk.Frame(window, padding=15)
|
|
135
|
-
main_frame.columnconfigure(0, weight=1)
|
|
136
|
-
main_frame.columnconfigure(1, weight=1)
|
|
137
|
-
main_frame.rowconfigure(0, weight=1)
|
|
138
|
-
|
|
139
|
-
self._configure_button_frame(main_frame)
|
|
140
|
-
self._configure_checkbox_frame(main_frame)
|
|
141
|
-
|
|
142
|
-
main_frame.pack(expand=True, fill="both")
|
|
143
|
-
|
|
144
|
-
def _configure_window(self):
|
|
145
|
-
"""Configure the main application window UI and add buttons for the main
|
|
146
|
-
functionalities.
|
|
147
|
-
"""
|
|
148
|
-
window = tk.Tk()
|
|
149
|
-
window.title(APPLICATION_NAME)
|
|
150
|
-
window.geometry(WINDOW_SIZE)
|
|
151
|
-
|
|
152
|
-
if OS == OSType.WINDOWS:
|
|
153
|
-
app_id = "cs2tracker.unique.id"
|
|
154
|
-
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(app_id)
|
|
155
|
-
|
|
156
|
-
icon = tk.PhotoImage(file=ICON_FILE)
|
|
157
|
-
window.wm_iconphoto(True, icon)
|
|
158
|
-
|
|
159
|
-
self._configure_main_frame(window)
|
|
160
|
-
|
|
161
|
-
return window
|
|
155
|
+
self._add_checkbox("Dark Theme", self.dark_theme_checkbox_value, sv_ttk.toggle_theme, 3)
|
|
162
156
|
|
|
163
157
|
def scrape_prices(self):
|
|
164
158
|
"""Scrape prices from the configured sources, print the total, and save the
|
|
165
159
|
results to a file.
|
|
166
160
|
"""
|
|
167
|
-
scraper_window = tk.Toplevel(self.
|
|
161
|
+
scraper_window = tk.Toplevel(self.parent)
|
|
168
162
|
scraper_window.geometry(SCRAPER_WINDOW_SIZE)
|
|
169
163
|
scraper_window.title(SCRAPER_WINDOW_TITLE)
|
|
170
164
|
|
|
@@ -179,7 +173,7 @@ class Application:
|
|
|
179
173
|
|
|
180
174
|
def _edit_config(self):
|
|
181
175
|
"""Open a new window with a config editor GUI."""
|
|
182
|
-
config_editor_window = tk.Toplevel(self.
|
|
176
|
+
config_editor_window = tk.Toplevel(self.parent)
|
|
183
177
|
config_editor_window.geometry(CONFIG_EDITOR_SIZE)
|
|
184
178
|
config_editor_window.title(CONFIG_EDITOR_TITLE)
|
|
185
179
|
|
|
@@ -235,6 +229,7 @@ class Application:
|
|
|
235
229
|
messagebox.showerror(
|
|
236
230
|
"Config Error",
|
|
237
231
|
"You need to enter a valid crawlbase API key into the configuration to use this feature.",
|
|
232
|
+
parent=self.parent,
|
|
238
233
|
)
|
|
239
234
|
return False
|
|
240
235
|
|
|
@@ -248,6 +243,7 @@ class Application:
|
|
|
248
243
|
messagebox.showerror(
|
|
249
244
|
"Config Error",
|
|
250
245
|
"You need to enter a valid Discord webhook URL into the configuration to use this feature.",
|
|
246
|
+
parent=self.parent,
|
|
251
247
|
)
|
|
252
248
|
return False
|
|
253
249
|
|