Skip to content

Commit 473f381

Browse files
committed
v2.3.0
1 parent 3d62c07 commit 473f381

25 files changed

+943
-794
lines changed

.flake8

Lines changed: 0 additions & 3 deletions
This file was deleted.

.gitignore

Lines changed: 176 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,177 @@
1-
.vscode
2-
__pycache__
3-
jsons
4-
config.py
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
share/python-wheels/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
MANIFEST
28+
29+
# PyInstaller
30+
# Usually these files are written by a python script from a template
31+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
32+
*.manifest
33+
*.spec
34+
35+
# Installer logs
36+
pip-log.txt
37+
pip-delete-this-directory.txt
38+
39+
# Unit test / coverage reports
40+
htmlcov/
41+
.tox/
42+
.nox/
43+
.coverage
44+
.coverage.*
45+
.cache
46+
nosetests.xml
47+
coverage.xml
48+
*.cover
49+
*.py,cover
50+
.hypothesis/
51+
.pytest_cache/
52+
cover/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
.pybuilder/
76+
target/
77+
78+
# Jupyter Notebook
79+
.ipynb_checkpoints
80+
81+
# IPython
82+
profile_default/
83+
ipython_config.py
84+
85+
# pyenv
86+
# For a library or package, you might want to ignore these files since the code is
87+
# intended to run in multiple environments; otherwise, check them in:
88+
# .python-version
89+
90+
# pipenv
91+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
93+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
94+
# install all needed dependencies.
95+
#Pipfile.lock
96+
97+
# UV
98+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99+
# This is especially recommended for binary packages to ensure reproducibility, and is more
100+
# commonly ignored for libraries.
101+
#uv.lock
102+
103+
# poetry
104+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105+
# This is especially recommended for binary packages to ensure reproducibility, and is more
106+
# commonly ignored for libraries.
107+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108+
#poetry.lock
109+
110+
# pdm
111+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112+
#pdm.lock
113+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114+
# in version control.
115+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116+
.pdm.toml
117+
.pdm-python
118+
.pdm-build/
119+
120+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121+
__pypackages__/
122+
123+
# Celery stuff
124+
celerybeat-schedule
125+
celerybeat.pid
126+
127+
# SageMath parsed files
128+
*.sage.py
129+
130+
# Environments
131+
.env
132+
.venv
133+
env/
134+
venv/
135+
ENV/
136+
env.bak/
137+
venv.bak/
138+
139+
# Spyder project settings
140+
.spyderproject
141+
.spyproject
142+
143+
# Rope project settings
144+
.ropeproject
145+
146+
# mkdocs documentation
147+
/site
148+
149+
# mypy
150+
.mypy_cache/
151+
.dmypy.json
152+
dmypy.json
153+
154+
# Pyre type checker
155+
.pyre/
156+
157+
# pytype static type analyzer
158+
.pytype/
159+
160+
# Cython debug symbols
161+
cython_debug/
162+
163+
# PyCharm
164+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166+
# and can be added to the global gitignore or merged into this file. For a more nuclear
167+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
168+
#.idea/
169+
170+
# Ruff stuff:
171+
.ruff_cache/
172+
173+
# PyPI configuration file
174+
.pypirc
175+
176+
# Other
5177
_build

.vscode/settings.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.defaultFormatter": "charliermarsh.ruff",
4+
"[python]": {
5+
"editor.codeActionsOnSave": {
6+
"source.organizeImports": "explicit"
7+
}
8+
}
9+
}

conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import pytest
2+
3+
4+
@pytest.fixture
5+
def marketplace_tf_api_key() -> str:
6+
return "api_key"
7+
8+
9+
@pytest.fixture
10+
def backpack_tf_token() -> str:
11+
return "backpack_tf_token"

src/tf2_utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# flake8: noqa
22
__title__ = "tf2-utils"
33
__author__ = "offish"
4-
__version__ = "2.2.0"
4+
__version__ = "2.3.0"
55
__license__ = "MIT"
66

77
from .sku import *

src/tf2_utils/backpack_tf.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import requests
2-
31
from dataclasses import dataclass, field
42
from hashlib import md5
53

6-
from .schema import SchemaItemsUtils
7-
from .sku import sku_to_quality, sku_is_craftable
8-
from . import __title__
4+
import requests
95

6+
from . import __title__
7+
from .schema import SchemaItemsUtils
8+
from .sku import sku_is_craftable, sku_to_quality
109

1110
__all__ = [
1211
"Currencies",

src/tf2_utils/currency.py

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def __init__(
2424
self.key_price = key_price
2525
self.item_is_not_pure = item_is_not_pure
2626

27-
self.__is_possible = False
27+
self._is_possible = False
2828
self.their_scrap = 0
2929
self.our_scrap = 0
3030
self.their_overview = {}
@@ -74,12 +74,8 @@ def get_pure_in_inventory(self, inventory: list[dict]) -> tuple[int, list[dict]]
7474

7575
return scrap, metal
7676

77-
def is_possible(self) -> bool:
78-
return self.__is_possible
79-
80-
def __overview_to_items(
81-
self, combination: list[str], inventory: list[dict]
82-
) -> list[dict]:
77+
@staticmethod
78+
def _overview_to_items(combination: list[str], inventory: list[dict]) -> list[dict]:
8379
items = []
8480

8581
for metal_name in combination:
@@ -97,12 +93,12 @@ def __overview_to_items(
9793
return items
9894

9995
def get_currencies(self) -> tuple[list[dict], list[dict]]:
100-
assert self.__is_possible, "Currencies does not add up"
96+
assert self._is_possible, "Currencies does not add up"
10197

102-
their_items = self.__overview_to_items(
98+
their_items = self._overview_to_items(
10399
self.their_combination, self.their_inventory
104100
)
105-
our_items = self.__overview_to_items(self.our_combination, self.our_inventory)
101+
our_items = self._overview_to_items(self.our_combination, self.our_inventory)
106102

107103
return their_items, our_items
108104

@@ -125,7 +121,7 @@ def format_overview(pure: list[dict]) -> dict:
125121

126122
return overview
127123

128-
def __pick_currencies(self, user: str) -> tuple[bool, list[str]]:
124+
def _pick_currencies(self, user: str) -> tuple[bool, list[str]]:
129125
"""ref, ref, scrap, rec"""
130126
overview = (
131127
self.their_overview.copy() if user == "them" else self.our_overview.copy()
@@ -166,7 +162,7 @@ def __pick_currencies(self, user: str) -> tuple[bool, list[str]]:
166162

167163
return True, combination
168164

169-
def __does_add_up(self) -> bool:
165+
def _adds_up(self) -> bool:
170166
their_value = 0
171167
our_value = 0
172168

@@ -184,9 +180,9 @@ def __does_add_up(self) -> bool:
184180

185181
return their_value == our_value
186182

187-
def __set_combinations(self) -> bool:
188-
success_our, our_combination = self.__pick_currencies("us")
189-
success_their, their_combination = self.__pick_currencies("them")
183+
def _set_combinations(self) -> bool:
184+
success_our, our_combination = self._pick_currencies("us")
185+
success_their, their_combination = self._pick_currencies("them")
190186

191187
if not success_our or not success_their:
192188
return False
@@ -196,7 +192,7 @@ def __set_combinations(self) -> bool:
196192

197193
return True
198194

199-
def __has_enough(self) -> bool:
195+
def _has_enough(self) -> bool:
200196
temp_price = self.scrap_price
201197

202198
if self.item_is_not_pure:
@@ -214,11 +210,11 @@ def calculate(self) -> None:
214210
self.their_overview = self.format_overview(their_pure)
215211
self.our_overview = self.format_overview(our_pure)
216212

217-
if not self.__has_enough():
213+
if not self._has_enough():
218214
return
219215

220-
while self.__has_enough():
221-
success = self.__set_combinations()
216+
while self._has_enough():
217+
success = self._set_combinations()
222218

223219
if success:
224220
break
@@ -227,8 +223,12 @@ def calculate(self) -> None:
227223
# try again, do this till we have either user does not have enough anymore
228224
self.scrap_price += 1
229225

230-
if not self.__does_add_up():
226+
if not self._adds_up():
231227
return
232228

233229
# everything adds up and looks good
234-
self.__is_possible = True
230+
self._is_possible = True
231+
232+
@property
233+
def is_possible(self) -> bool:
234+
return self._is_possible

src/tf2_utils/inventory.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import requests
2+
3+
from .providers.custom import Custom
4+
from .providers.steamapis import SteamApis
15
from .providers.steamcommunity import SteamCommunity
26
from .providers.steamsupply import SteamSupply
3-
from .providers.steamapis import SteamApis
4-
from .providers.custom import Custom
57
from .sku import get_sku
68

7-
import requests
8-
99

1010
def map_inventory(inventory: dict, add_skus: bool = False) -> list[dict]:
1111
"""Matches classids and instanceids, merges these and

src/tf2_utils/item.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from tf2_data import QUALITIES, KILLSTREAKS, EXTERIORS
1+
from tf2_data import EXTERIORS, KILLSTREAKS, QUALITIES
22

33

44
class Item:

src/tf2_utils/marketplace_tf.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
from .schema import SchemaItemsUtils
2-
from .sku import sku_to_quality_name, sku_is_craftable
3-
41
import time
52

63
import requests
74

5+
from .schema import SchemaItemsUtils
6+
from .sku import sku_is_craftable, sku_to_quality_name
87

98
__all__ = ["MarketplaceTF", "MarketplaceTFException", "SKUDoesNotMatch", "NoAPIKey"]
109

0 commit comments

Comments
 (0)