cs2tracker 2.1.8__py3-none-any.whl → 2.1.10__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.

@@ -0,0 +1,117 @@
1
+ import re
2
+ from configparser import ConfigParser
3
+
4
+ from cs2tracker.constants import CAPSULE_INFO, CONFIG_FILE
5
+ from cs2tracker.padded_console import PaddedConsole
6
+
7
+ console = PaddedConsole()
8
+
9
+
10
+ STEAM_MARKET_LISTING_REGEX = r"^https://steamcommunity.com/market/listings/\d+/.+$"
11
+
12
+
13
+ class ValidatedConfig(ConfigParser):
14
+ def __init__(self):
15
+ """Initialize the ValidatedConfig class."""
16
+ super().__init__(delimiters=("~"), interpolation=None)
17
+ self.optionxform = str # type: ignore
18
+ super().read(CONFIG_FILE)
19
+
20
+ self.valid = False
21
+ self.last_error = None
22
+ self._validate_config()
23
+
24
+ def _validate_config_sections(self):
25
+ """Validate that the configuration file has all required sections."""
26
+ if not self.has_section("User Settings"):
27
+ raise ValueError("Missing 'User Settings' section in the configuration file.")
28
+ if not self.has_section("App Settings"):
29
+ raise ValueError("Missing 'App Settings' section in the configuration file.")
30
+ if not self.has_section("Custom Items"):
31
+ raise ValueError("Missing 'Custom Items' section in the configuration file.")
32
+ if not self.has_section("Cases"):
33
+ raise ValueError("Missing 'Cases' section in the configuration file.")
34
+ for capsule_section in CAPSULE_INFO:
35
+ if not self.has_section(capsule_section):
36
+ raise ValueError(f"Missing '{capsule_section}' section in the configuration file.")
37
+
38
+ def _validate_config_values(self):
39
+ """Validate that the configuration file has valid values for all sections."""
40
+ try:
41
+ for custom_item_href, custom_item_owned in self.items("Custom Items"):
42
+ if not re.match(STEAM_MARKET_LISTING_REGEX, custom_item_href):
43
+ raise ValueError(
44
+ f"Invalid Steam market listing URL in 'Custom Items' section: {custom_item_href}"
45
+ )
46
+
47
+ if int(custom_item_owned) < 0:
48
+ raise ValueError(
49
+ f"Invalid value in 'Custom Items' section: {custom_item_href} = {custom_item_owned}"
50
+ )
51
+ for case_name, case_owned in self.items("Cases"):
52
+ if int(case_owned) < 0:
53
+ raise ValueError(
54
+ f"Invalid value in 'Cases' section: {case_name} = {case_owned}"
55
+ )
56
+ for capsule_section in CAPSULE_INFO:
57
+ for capsule_name, capsule_owned in self.items(capsule_section):
58
+ if int(capsule_owned) < 0:
59
+ raise ValueError(
60
+ f"Invalid value in '{capsule_section}' section: {capsule_name} = {capsule_owned}"
61
+ )
62
+ except ValueError as error:
63
+ if "Invalid " in str(error):
64
+ raise
65
+ raise ValueError("Invalid value type. All values must be integers.") from error
66
+
67
+ def _validate_config(self):
68
+ """
69
+ Validate the configuration file to ensure all required sections exist with the
70
+ right values.
71
+
72
+ :raises ValueError: If any required section is missing or if any value is
73
+ invalid.
74
+ """
75
+ try:
76
+ self._validate_config_sections()
77
+ self._validate_config_values()
78
+ self.valid = True
79
+ except ValueError as error:
80
+ console.print(f"[bold red][!] Config error: {error}")
81
+ self.valid = False
82
+ self.last_error = error
83
+
84
+ def write_to_file(self):
85
+ """Write the current configuration to the configuration file."""
86
+ self._validate_config()
87
+
88
+ if self.valid:
89
+ with open(CONFIG_FILE, "w", encoding="utf-8") as config_file:
90
+ self.write(config_file)
91
+
92
+ def toggle_use_proxy(self, enabled: bool):
93
+ """
94
+ Toggle the use of proxies for requests. This will update the configuration file.
95
+
96
+ :param enabled: If True, proxies will be used; if False, they will not be used.
97
+ """
98
+ self.set("App Settings", "use_proxy", str(enabled))
99
+ self.write_to_file()
100
+
101
+ console.print(
102
+ f"[bold green]{'[+] Enabled' if enabled else '[-] Disabled'} proxy usage for requests."
103
+ )
104
+
105
+ def toggle_discord_webhook(self, enabled: bool):
106
+ """
107
+ Toggle the use of a Discord webhook to notify users of price calculations.
108
+
109
+ :param enabled: If True, the webhook will be used; if False, it will not be
110
+ used.
111
+ """
112
+ self.set("App Settings", "discord_notifications", str(enabled))
113
+ self.write_to_file()
114
+
115
+ console.print(
116
+ f"[bold green]{'[+] Enabled' if enabled else '[-] Disabled'} Discord webhook notifications."
117
+ )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cs2tracker
3
- Version: 2.1.8
3
+ Version: 2.1.10
4
4
  Summary: Tracking the steam market prices of CS2 items
5
5
  Home-page: https://github.com/ashiven/cs2tracker
6
6
  Author: Jannik Novak
@@ -19,6 +19,7 @@ Requires-Dist: Requests==2.31.0
19
19
  Requires-Dist: rich==13.6.0
20
20
  Requires-Dist: tenacity==8.2.2
21
21
  Requires-Dist: urllib3==2.1.0
22
+ Requires-Dist: sv_ttk==2.6.1
22
23
  Dynamic: license-file
23
24
 
24
25
  <div align="center">
@@ -46,7 +47,7 @@ Dynamic: license-file
46
47
 
47
48
  ### Setup
48
49
 
49
- #### Windows Executable _(no color support)_
50
+ #### Windows Executable
50
51
 
51
52
  - Simply [download the latest executable](https://github.com/ashiven/cs2tracker/releases/latest/download/cs2tracker-windows.zip) and run it.
52
53
 
@@ -67,11 +68,13 @@ Dynamic: license-file
67
68
  ### Options
68
69
 
69
70
  - `Run!` to gather the current market prices of your items and calculate the total amount in USD and EUR.
70
- - `Edit Config` to specify the numbers of items owned in the config file. You can also add items other than cases and sticker capsules following the format in the `Custom Items` section. (item_name = item_owned item_page)
71
+ - `Edit Config` to specify the numbers of items owned in the configuration. You can also add items other than cases and sticker capsules via `Add Custom Item`
72
+ - `Reset Config` to reset the configuration to its original state. This will remove any custom items you have added and reset the number of items owned for all items.
71
73
  - `Show History` to see a price chart consisting of past calculations. A new data point is generated once a day upon running the program.
74
+ - `Export / Import History` to export the price history to a CSV file or import it from a CSV file. This may be used to back up your history data or perform further analysis on it.
72
75
  - `Daily Background Calculations` to automatically run a daily calculation of your investment in the background and save the results such that they can later be viewed via `Show History`.
73
76
  - `Receive Discord Notifications` to receive a notification on your Discord server when the program has finished calculating your investment. You need to set up a [webhook](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks) in your Discord server and enter the webhook url into the `discord_webhook_url` field in the config file.
74
- - `Proxy Requests` to prevent your requests from being rate limited by the steamcommunity server. You need to register for a free API key on [Crawlbase](crawlbase.com) and enter it into the `api_key` field in the config file.
77
+ - `Proxy Requests` to prevent your requests from being rate limited by the steamcommunity server. You need to register for a free API key on [Crawlbase](crawlbase.com) and enter it into the `proxy_api_key` field in the `User Settings` configuration section.
75
78
 
76
79
  ---
77
80
 
@@ -0,0 +1,20 @@
1
+ cs2tracker/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ cs2tracker/__main__.py,sha256=Ub--oSMv48YzfWF1CZqYlkn1-HvZ7Bhxoc7urn1oY6o,249
3
+ cs2tracker/_version.py,sha256=I6C3mOmr0C_Y2pXczUFpTwSLzslDJ4SYKuba821hgTs,513
4
+ cs2tracker/application.py,sha256=Iey8yKyZaKhxqBNGLvxJngOSnfWaQLXc8iz40iYFh7M,20203
5
+ cs2tracker/background_task.py,sha256=qXALj85FlDmC3-7ifYWQCP0KrLTDBCbqPyXMFqIdMP0,3713
6
+ cs2tracker/constants.py,sha256=5pfzR5hjmpd3VW6UOlUd0hTheNRV2RLiYif6jX-U04E,27410
7
+ cs2tracker/discord_notifier.py,sha256=UIXE4xADLpWI3uoLstSxfo-6zCXGHyFiWe0pGWq1BKM,3037
8
+ cs2tracker/main.py,sha256=jXEgZIpM_cDENXOaXCVTg2n50Xso7btI5FImg9BBeXQ,1041
9
+ cs2tracker/padded_console.py,sha256=lPEa34p-8LTmTbpf-2S5uYPaA2UmsIOPq2_UoVhMRgU,674
10
+ cs2tracker/price_logs.py,sha256=JuZ2ptDtxA-NzKjpG_4q0eeOr1IaUvVah-Qth6GrDDU,4165
11
+ cs2tracker/scraper.py,sha256=4MGa-9bB3uHT38n6Nx-eAF6rRX8PyS5GfVv4dCjmQDI,12818
12
+ cs2tracker/validated_config.py,sha256=kjwOSR4Opqa-qo_8leB87l3lzNgUjgDIDAQ-h8_ubnE,4785
13
+ cs2tracker/data/config.ini,sha256=FxFLaSLY3Uxtbuj7KF77NqO_Jr_BUWZEPjiFUCymtnI,5041
14
+ cs2tracker/data/output.csv,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
+ cs2tracker-2.1.10.dist-info/licenses/LICENSE.md,sha256=G5wqQ_8KGA808kVuF-Fpu_Yhteg8K_5ux9n2v8eQK7s,1069
16
+ cs2tracker-2.1.10.dist-info/METADATA,sha256=YctLnRkkoCIsdg5pCYyISndMEHYI8cSleLfPSE8azM8,4060
17
+ cs2tracker-2.1.10.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
18
+ cs2tracker-2.1.10.dist-info/entry_points.txt,sha256=K8IwDIkg8QztSB9g9c89B9jR_2pG4QyJGrNs4z5RcZw,63
19
+ cs2tracker-2.1.10.dist-info/top_level.txt,sha256=2HB4xDDOxaU5BDc_yvdi9UlYLgL768n8aR-hRhFM6VQ,11
20
+ cs2tracker-2.1.10.dist-info/RECORD,,
@@ -1,16 +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=JNwYT7L17W6XA8Q9TFeLnVI0FvK7eOV1TLduK2unwJc,511
4
- cs2tracker/application.py,sha256=NpufwEEpe1lXG0KxvfxI2b6vvNQta_uSyN3m7deaTxQ,9018
5
- cs2tracker/constants.py,sha256=swkxVJQSwvavTorL3t_pBOHLtcgP3SaU9SU98XXuj48,29199
6
- cs2tracker/main.py,sha256=jXEgZIpM_cDENXOaXCVTg2n50Xso7btI5FImg9BBeXQ,1041
7
- cs2tracker/padded_console.py,sha256=lPEa34p-8LTmTbpf-2S5uYPaA2UmsIOPq2_UoVhMRgU,674
8
- cs2tracker/scraper.py,sha256=EhpHR3bHKgo0IgzFN7wAjKfiUwnvLhszXodgx8apvz4,22577
9
- cs2tracker/data/config.ini,sha256=960jvrTt6ZOwCrHTVC5Q4Uw9lVGNnVRY7-kG6-k_Mig,5197
10
- cs2tracker/data/output.csv,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- cs2tracker-2.1.8.dist-info/licenses/LICENSE.md,sha256=G5wqQ_8KGA808kVuF-Fpu_Yhteg8K_5ux9n2v8eQK7s,1069
12
- cs2tracker-2.1.8.dist-info/METADATA,sha256=ncKNzK2yKBMWWFB07kH4s4D5aP7O5qrYol-2_QFOIwo,3734
13
- cs2tracker-2.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- cs2tracker-2.1.8.dist-info/entry_points.txt,sha256=K8IwDIkg8QztSB9g9c89B9jR_2pG4QyJGrNs4z5RcZw,63
15
- cs2tracker-2.1.8.dist-info/top_level.txt,sha256=2HB4xDDOxaU5BDc_yvdi9UlYLgL768n8aR-hRhFM6VQ,11
16
- cs2tracker-2.1.8.dist-info/RECORD,,