steam-client 0.0.1.dev1__tar.gz → 1.0.0.dev0__tar.gz

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.
Files changed (20) hide show
  1. {steam-client-0.0.1.dev1/steam_client.egg-info → steam-client-1.0.0.dev0}/PKG-INFO +2 -1
  2. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/pyproject.toml +4 -2
  3. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/login_users.py +19 -20
  4. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/shortcut.py +11 -11
  5. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/steam.py +8 -3
  6. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/utils.py +7 -2
  7. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0/steam_client.egg-info}/PKG-INFO +2 -1
  8. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/LICENSE +0 -0
  9. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/setup.cfg +0 -0
  10. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/setup.py +0 -0
  11. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/__init__.py +0 -0
  12. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/app.py +0 -0
  13. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/commands.py +0 -0
  14. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/game.py +0 -0
  15. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/library.py +0 -0
  16. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/library_directory.py +0 -0
  17. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client/web_api.py +0 -0
  18. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client.egg-info/SOURCES.txt +0 -0
  19. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client.egg-info/dependency_links.txt +0 -0
  20. {steam-client-0.0.1.dev1 → steam-client-1.0.0.dev0}/steam_client.egg-info/top_level.txt +0 -0
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: steam-client
3
- Version: 0.0.1.dev1
3
+ Version: 1.0.0.dev0
4
4
  Summary: Steam client library for Python
5
5
  Author-email: William McAllister <dev.garulf@gmail.com>
6
6
  License: MIT
7
+ Project-URL: Source, https://github.com/garulf/steam-client
7
8
  Classifier: License :: OSI Approved :: MIT License
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: Programming Language :: Python :: 3 :: Only
@@ -6,7 +6,7 @@ name = "steam-client"
6
6
  authors = [
7
7
  {name = "William McAllister", email = "dev.garulf@gmail.com"}
8
8
  ]
9
- version = '0.0.1-dev.1'
9
+ version = '1.0.0-dev.0'
10
10
  description = "Steam client library for Python"
11
11
  readme = "README.md"
12
12
  requires-python = ">=3.8"
@@ -16,12 +16,14 @@ classifiers = [
16
16
  "Programming Language :: Python :: 3",
17
17
  "Programming Language :: Python :: 3 :: Only",
18
18
  ]
19
+ [project.urls]
20
+ Source = "https://github.com/garulf/steam-client"
19
21
 
20
22
  [tool.setuptools]
21
23
  packages = ["steam_client"]
22
24
 
23
25
  [tool.bumpversion]
24
- current_version = "0.0.1-dev"
26
+ current_version = "0.0.1-rc.0"
25
27
  parse = """(?x)
26
28
  (?P<major>[0-9]+)
27
29
  \\.(?P<minor>[0-9]+)
@@ -1,11 +1,10 @@
1
1
  from __future__ import annotations
2
2
  from dataclasses import dataclass
3
3
  from pathlib import Path
4
- from typing import Dict, List, Optional
4
+ from typing import List, Optional
5
5
  from typing import TYPE_CHECKING
6
- from typing import TypedDict
7
6
 
8
- import vdf
7
+ import vdf # type: ignore
9
8
 
10
9
  if TYPE_CHECKING:
11
10
  from steam_client.steam import Steam
@@ -15,7 +14,14 @@ from .shortcut import Shortcut
15
14
  STEAM64_OFFSET = 76561197960265728
16
15
 
17
16
 
18
- class UserData(TypedDict):
17
+ @dataclass
18
+ class User:
19
+ id: int
20
+ data: UserData
21
+
22
+
23
+ @dataclass
24
+ class UserData:
19
25
  AccountName: str
20
26
  PersonaName: str
21
27
  RememberPassword: str
@@ -26,29 +32,22 @@ class UserData(TypedDict):
26
32
  Timestamp: str
27
33
 
28
34
 
29
- UserLoginsFile = Dict[str, Dict[str, UserData]]
30
-
31
-
32
- class User:
35
+ class LoginUser:
33
36
  """Represents a current or previous logged in Steam user."""
34
37
 
35
- def __init__(self, steam: Steam, steam_id64: str, user_data: UserData):
38
+ def __init__(self, steam: Steam, user: User):
36
39
  self._steam = steam
37
- self.steam_id64 = steam_id64
38
- self._user_data = user_data
39
-
40
- def __repr__(self) -> str:
41
- return f'User(steam={self._steam.__repr__()}, steam_id64={self.steam_id64.__repr__()}, user_data={self._user_data.__repr__()})'
40
+ self.user = user
42
41
 
43
42
  @property
44
43
  def is_most_recent(self) -> bool:
45
44
  """Returns whether the user is the most recent user."""
46
- return self._user_data['MostRecent'] == '1'
45
+ return self.user.data.MostRecent == '1'
47
46
 
48
47
  @property
49
48
  def steam_id3(self) -> int:
50
49
  """Returns the last portion of the user's SteamID3."""
51
- steamidacct = (int(self.steam_id64) - STEAM64_OFFSET)
50
+ steamidacct = (int(self.user.id) - STEAM64_OFFSET)
52
51
  return steamidacct
53
52
 
54
53
  @property
@@ -89,12 +88,12 @@ class LoginUsers:
89
88
  """Returns the path to the loginusers.vdf file."""
90
89
  return Path(self._steam.base_path).joinpath('config', 'loginusers.vdf')
91
90
 
92
- def users(self) -> List[User]:
91
+ def users(self) -> List[LoginUser]:
93
92
  """Returns the users from the loginusers.vdf file."""
94
93
  with open(self._path, 'r', encoding='utf-8', errors='ignore') as f:
95
- login_users: UserLoginsFile = vdf.load(f)
96
- return [User(self._steam, steam_id64, user_data) for steam_id64, user_data in login_users['users'].items()]
94
+ login_users = vdf.load(f)
95
+ return [LoginUser(self._steam, User(int(user_id), user_data)) for user_id, user_data in login_users['users'].items()]
97
96
 
98
- def most_recent_user(self) -> Optional[User]:
97
+ def most_recent_user(self) -> Optional[LoginUser]:
99
98
  """Returns the most recent user from the loginusers.vdf file."""
100
99
  return next((user for user in self.users() if user.is_most_recent), None)
@@ -3,11 +3,11 @@ from pathlib import Path
3
3
  from typing import TYPE_CHECKING, Dict
4
4
  from typing import TypedDict
5
5
 
6
- import pycrc.algorithms as crc
6
+ import pycrc.algorithms as crc # type: ignore
7
7
 
8
8
  if TYPE_CHECKING:
9
9
  from .steam import Steam
10
- from .login_users import User
10
+ from .login_users import LoginUser
11
11
 
12
12
  from .app import App
13
13
 
@@ -25,7 +25,7 @@ class ShortcutEntry(TypedDict):
25
25
  class Shortcut(App):
26
26
  """Represents a Non-Steam Game shortcut."""
27
27
 
28
- def __init__(self, steam: Steam, user: User, data: ShortcutEntry):
28
+ def __init__(self, steam: Steam, user: LoginUser, data: ShortcutEntry):
29
29
  self._data = data
30
30
  self._user = user
31
31
  super().__init__(steam)
@@ -54,17 +54,17 @@ class Shortcut(App):
54
54
  return str(int(self.appid) >> int(32))
55
55
 
56
56
  @property
57
- def icon(self) -> str:
58
- return self._data["icon"] or str(self._user.grid_path.joinpath(f"{self._short_id()}_icon.png"))
57
+ def icon(self) -> Path:
58
+ return Path(self._data["icon"]) or self._user.grid_path.joinpath(f"{self._short_id()}_icon.png")
59
59
 
60
60
  @property
61
- def header(self) -> str:
62
- return str(self._user.grid_path.joinpath(f"{self._short_id()}.png"))
61
+ def header(self) -> Path:
62
+ return self._user.grid_path.joinpath(f"{self._short_id()}.png")
63
63
 
64
64
  @property
65
- def grid(self) -> str:
66
- return str(self._user.grid_path.joinpath(f"{self._short_id()}p.png"))
65
+ def grid(self) -> Path:
66
+ return self._user.grid_path.joinpath(f"{self._short_id()}p.png")
67
67
 
68
68
  @property
69
- def hero(self) -> str:
70
- return str(self._user.grid_path.joinpath(f"{self._short_id()}_hero.png"))
69
+ def hero(self) -> Path:
70
+ return self._user.grid_path.joinpath(f"{self._short_id()}_hero.png")
@@ -1,4 +1,3 @@
1
- import functools
2
1
  from pathlib import Path
3
2
 
4
3
  from .library import Library
@@ -13,9 +12,7 @@ class Steam:
13
12
 
14
13
  def __init__(self, base_path: str = DEFAULT_WIN_STEAM_PATH):
15
14
  self.base_path: str = base_path
16
- self.login_users = LoginUsers(self)
17
15
  self.commands = Commands()
18
- self.library = Library(self)
19
16
 
20
17
  def __repr__(self) -> str:
21
18
  return f'Steam(base_path={self.base_path.__repr__()})'
@@ -39,3 +36,11 @@ class Steam:
39
36
  def library_cache(self) -> Path:
40
37
  """Returns the path to the librarycache folder."""
41
38
  return Path(self.base_path).joinpath('appcache', 'librarycache')
39
+
40
+ @property
41
+ def users(self):
42
+ return LoginUsers(self).users()
43
+
44
+ @property
45
+ def library(self) -> Library:
46
+ return Library(self)
@@ -7,7 +7,12 @@ from .steam import Steam
7
7
  STEAM_SUB_KEY = r'SOFTWARE\WOW6432Node\Valve\Steam'
8
8
 
9
9
 
10
+ def get_steam_from_registry() -> str:
11
+ """Returns the Steam install path from the Windows registry."""
12
+ with reg.OpenKey(HKEY_LOCAL_MACHINE, STEAM_SUB_KEY) as hkey:
13
+ return reg.QueryValueEx(hkey, "InstallPath")[0]
14
+
15
+
10
16
  def steam_from_registry() -> Steam:
11
17
  """Returns a Steam instance from the Windows registry."""
12
- with reg.OpenKey(HKEY_LOCAL_MACHINE, STEAM_SUB_KEY) as hkey:
13
- return Steam(reg.QueryValueEx(hkey, "InstallPath")[0])
18
+ return Steam(get_steam_from_registry())
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: steam-client
3
- Version: 0.0.1.dev1
3
+ Version: 1.0.0.dev0
4
4
  Summary: Steam client library for Python
5
5
  Author-email: William McAllister <dev.garulf@gmail.com>
6
6
  License: MIT
7
+ Project-URL: Source, https://github.com/garulf/steam-client
7
8
  Classifier: License :: OSI Approved :: MIT License
8
9
  Classifier: Programming Language :: Python :: 3
9
10
  Classifier: Programming Language :: Python :: 3 :: Only