usos-api 0.3.1__tar.gz → 0.3.3__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 (31) hide show
  1. {usos_api-0.3.1 → usos_api-0.3.3}/PKG-INFO +3 -3
  2. {usos_api-0.3.1 → usos_api-0.3.3}/pyproject.toml +1 -1
  3. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/auth.py +13 -5
  4. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/client.py +7 -2
  5. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/connection.py +11 -3
  6. {usos_api-0.3.1 → usos_api-0.3.3}/README.md +0 -0
  7. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/__init__.py +0 -0
  8. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/exceptions.py +0 -0
  9. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/helper.py +0 -0
  10. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/logger.py +0 -0
  11. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/__init__.py +0 -0
  12. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/api_documentation.py +0 -0
  13. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/consumer.py +0 -0
  14. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/course.py +0 -0
  15. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/grade.py +0 -0
  16. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/group.py +0 -0
  17. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/lang_dict.py +0 -0
  18. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/programme.py +0 -0
  19. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/registration.py +0 -0
  20. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/term.py +0 -0
  21. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/models/user.py +0 -0
  22. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/__init__.py +0 -0
  23. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/api_documentation.py +0 -0
  24. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/api_server.py +0 -0
  25. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/courses.py +0 -0
  26. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/grades.py +0 -0
  27. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/groups.py +0 -0
  28. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/registrations.py +0 -0
  29. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/terms.py +0 -0
  30. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/services/users.py +0 -0
  31. {usos_api-0.3.1 → usos_api-0.3.3}/usos_api/utils/__init__.py +0 -0
@@ -1,8 +1,7 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: usos-api
3
- Version: 0.3.1
3
+ Version: 0.3.3
4
4
  Summary: Asynchronous USOS API for Python
5
- Home-page: https://github.com/Antoni-Czaplicki/usos-api
6
5
  Author: Antoni-Czaplicki
7
6
  Author-email: 56671347+Antoni-Czaplicki@users.noreply.github.com
8
7
  Requires-Python: >=3.10,<4.0
@@ -16,6 +15,7 @@ Requires-Dist: oauthlib (>=3.2,<4.0)
16
15
  Requires-Dist: pydantic (>=2.10,<3.0)
17
16
  Requires-Dist: python-dotenv (>=1.0,<2.0)
18
17
  Project-URL: Documentation, https://usos-api.readthedocs.io
18
+ Project-URL: Homepage, https://github.com/Antoni-Czaplicki/usos-api
19
19
  Project-URL: Repository, https://github.com/Antoni-Czaplicki/usos-api
20
20
  Description-Content-Type: text/markdown
21
21
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "usos-api"
3
- version = "0.3.1"
3
+ version = "0.3.3"
4
4
  description = "Asynchronous USOS API for Python"
5
5
  authors = ["Antoni-Czaplicki <56671347+Antoni-Czaplicki@users.noreply.github.com>"]
6
6
  readme = "README.md"
@@ -21,13 +21,20 @@ class AuthManager:
21
21
  # List of available scopes can be found at https://apps.usos.edu.pl/developers/api/authorization/#scopes
22
22
  SCOPES = "|".join(["offline_access", "studies"])
23
23
 
24
- def __init__(self, api_base_address: str, consumer_key: str, consumer_secret: str):
24
+ def __init__(
25
+ self,
26
+ api_base_address: str,
27
+ consumer_key: str,
28
+ consumer_secret: str,
29
+ trust_env: bool = False,
30
+ ):
25
31
  """
26
32
  Initialize the authentication manager.
27
33
 
28
34
  :param api_base_address: The base address of the USOS API.
29
35
  :param consumer_key: Consumer key obtained from the USOS API.
30
36
  :param consumer_secret: Consumer secret obtained from the USOS API.
37
+ :param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
31
38
  """
32
39
  self.base_address = api_base_address.rstrip("/") + "/"
33
40
  self.consumer_key = consumer_key
@@ -35,6 +42,7 @@ class AuthManager:
35
42
  self.access_token = None
36
43
  self.access_token_secret = None
37
44
  self._session = None
45
+ self.trust_env = trust_env
38
46
  self._oauth_client = Client(consumer_key, consumer_secret)
39
47
 
40
48
  async def __aenter__(self) -> "AuthManager":
@@ -60,7 +68,7 @@ class AuthManager:
60
68
  """
61
69
  Open the manager.
62
70
  """
63
- self._session = aiohttp.ClientSession()
71
+ self._session = aiohttp.ClientSession(trust_env=self.trust_env)
64
72
 
65
73
  async def close(self):
66
74
  """
@@ -93,7 +101,7 @@ class AuthManager:
93
101
  self._request_token_secret = data["oauth_token_secret"]
94
102
  self._oauth_client.resource_owner_key = self._request_token
95
103
  self._oauth_client.resource_owner_secret = self._request_token_secret
96
- _LOGGER.info(f"New request token generated: {self._request_token}")
104
+ _LOGGER.debug(f"New request token generated")
97
105
 
98
106
  async def get_authorization_url(
99
107
  self, callback_url: str, confirm_user: bool = False
@@ -131,8 +139,8 @@ class AuthManager:
131
139
  await self._handle_response_errors(response)
132
140
  data = dict(urllib.parse.parse_qsl(await response.text()))
133
141
  self.load_access_token(data["oauth_token"], data["oauth_token_secret"])
134
- _LOGGER.info(
135
- f"Authorization successful, received access token: {self.access_token}"
142
+ _LOGGER.debug(
143
+ f"Authorization successful, received access token"
136
144
  )
137
145
  return self.access_token, self.access_token_secret
138
146
  except AttributeError as e:
@@ -34,7 +34,11 @@ class USOSClient:
34
34
  """
35
35
 
36
36
  def __init__(
37
- self, api_base_address: str, consumer_key: str, consumer_secret: str
37
+ self,
38
+ api_base_address: str,
39
+ consumer_key: str,
40
+ consumer_secret: str,
41
+ trust_env: bool = False,
38
42
  ) -> None:
39
43
  """
40
44
  Initialize the USOS API client.
@@ -42,9 +46,10 @@ class USOSClient:
42
46
  :param api_base_address: The base address of the USOS API.
43
47
  :param consumer_key: Consumer key obtained from the USOS API.
44
48
  :param consumer_secret: Consumer secret obtained from the USOS API.
49
+ :param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
45
50
  """
46
51
  self.connection = USOSAPIConnection(
47
- api_base_address, consumer_key, consumer_secret
52
+ api_base_address, consumer_key, consumer_secret, trust_env
48
53
  )
49
54
  self.user_service = UserService(self.connection)
50
55
  self.group_service = GroupService(self.connection)
@@ -15,19 +15,27 @@ class USOSAPIConnection:
15
15
  A connection to the USOS API.
16
16
  """
17
17
 
18
- def __init__(self, api_base_address: str, consumer_key: str, consumer_secret: str):
18
+ def __init__(
19
+ self,
20
+ api_base_address: str,
21
+ consumer_key: str,
22
+ consumer_secret: str,
23
+ trust_env: bool = False,
24
+ ):
19
25
  """
20
26
  Initialize the USOS API connection.
21
27
 
22
28
  :param api_base_address: The base address of the USOS API.
23
29
  :param consumer_key: Consumer key obtained from the USOS API.
24
30
  :param consumer_secret: Consumer secret obtained from the USOS API.
31
+ :param trust_env: Whether to trust the environment variables for the connection, see https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession for more information.
25
32
  """
26
33
  self.base_address = api_base_address.rstrip("/") + "/"
27
34
  self.auth_manager = AuthManager(
28
- self.base_address, consumer_key, consumer_secret
35
+ self.base_address, consumer_key, consumer_secret, trust_env
29
36
  )
30
37
  self._session = None
38
+ self.trust_env = trust_env
31
39
 
32
40
  async def __aenter__(self) -> "USOSAPIConnection":
33
41
  """
@@ -52,7 +60,7 @@ class USOSAPIConnection:
52
60
  """
53
61
  Open the connection.
54
62
  """
55
- self._session = aiohttp.ClientSession()
63
+ self._session = aiohttp.ClientSession(trust_env=self.trust_env)
56
64
  await self.auth_manager.open()
57
65
 
58
66
  async def close(self):
File without changes
File without changes
File without changes
File without changes