schoolmospy 0.0.2__tar.gz → 0.2.1__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.
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: schoolmospy
3
+ Version: 0.2.1
4
+ Summary: A lightweight async Python wrapper for school.mos.ru APIs
5
+ License: GPL-3.0-only
6
+ License-File: LICENSE
7
+ Keywords: school,mos,api,education,async,wrapper,python
8
+ Author: Ivan Kriventsev
9
+ Author-email: xd2dd@icloud.com
10
+ Requires-Python: >=3.12
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Requires-Dist: aiohttp (>=3.12.15,<4.0.0)
17
+ Requires-Dist: httpx (>=0.28.1,<0.29.0)
18
+ Requires-Dist: pydantic (>=2.11.9,<3.0.0)
19
+ Project-URL: Documentation, https://xd2dd.github.io/schoolmospy
20
+ Project-URL: Homepage, https://github.com/xd2dd/schoolmospy
21
+ Project-URL: Issues, https://github.com/xd2dd/schoolmospy/issues
22
+ Description-Content-Type: text/markdown
23
+
24
+ ![Badge](https://img.shields.io/badge/version-0.2.0-blue.svg)
25
+ ![Python](https://img.shields.io/badge/python-3.12+-blue.svg)
26
+ ![License](https://img.shields.io/badge/license-GPL--3.0-green.svg)
27
+
28
+ # 📕 SchoolMosPy
29
+
30
+ SchoolMosPy is a lightweight async Python wrapper for school.mos.ru APIs. It provides a simple and intuitive interface to interact with the Moscow School Electronic Diary platform.
31
+
32
+ ## ✨ Features
33
+
34
+ - **Async architecture** - built on `aiohttp` and `httpx` for high performance
35
+ - **Type safety** - uses `pydantic` for data validation
36
+ - **Simple API** - intuitive interface for working with data
37
+ - **Full-featured** - access to marks, homeworks, events, and profile data
38
+
39
+ ## 📋 Requirements
40
+
41
+ - Python 3.12+
42
+ - aiohttp >= 3.12.15
43
+ - pydantic >= 2.11.9
44
+ - httpx >= 0.28.1
45
+
46
+ ## 📦 Installation
47
+
48
+ ```bash
49
+ pip install schoolmospy
50
+ ```
51
+
52
+ ## 🚀 Quick Start
53
+
54
+ ```python
55
+ import asyncio
56
+ from schoolmospy import StudentClient
57
+
58
+ async def main():
59
+ # Create client
60
+ client = StudentClient(
61
+ token="your_token",
62
+ profile_id=12345
63
+ )
64
+
65
+ # Get profile
66
+ profile = await client.get_me()
67
+ print(f"Name: {profile.name}")
68
+
69
+ # Get marks
70
+ marks = await client.marks.get_marks(
71
+ from_date="2024-01-01",
72
+ to_date="2024-12-31"
73
+ )
74
+
75
+ # Get homeworks
76
+ homeworks = await client.homeworks.get_homeworks(
77
+ from_date="2024-01-01",
78
+ to_date="2024-12-31"
79
+ )
80
+
81
+ # Get events/schedule
82
+ events = await client.events.get_events(
83
+ from_date="2024-01-01",
84
+ to_date="2024-12-31"
85
+ )
86
+
87
+ await client.close()
88
+
89
+ asyncio.run(main())
90
+ ```
91
+
92
+ ## 📝 License
93
+
94
+ This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.
95
+
96
+ ## 🔗 Links
97
+
98
+ - [Documentation](https://xd2dd.github.io/schoolmospy)
99
+ - [Report an Issue](https://github.com/xd2dd/schoolmospy/issues)
100
+
101
+ ## 👨‍💻 Author
102
+
103
+ Ivan Kriventsev - [xd2dd@icloud.com](mailto:xd2dd@icloud.com)
104
+
105
+ ---
106
+
107
+ ⭐ If you like this project, please give it a star on GitHub!
108
+
@@ -0,0 +1,84 @@
1
+ ![Badge](https://img.shields.io/badge/version-0.2.0-blue.svg)
2
+ ![Python](https://img.shields.io/badge/python-3.12+-blue.svg)
3
+ ![License](https://img.shields.io/badge/license-GPL--3.0-green.svg)
4
+
5
+ # 📕 SchoolMosPy
6
+
7
+ SchoolMosPy is a lightweight async Python wrapper for school.mos.ru APIs. It provides a simple and intuitive interface to interact with the Moscow School Electronic Diary platform.
8
+
9
+ ## ✨ Features
10
+
11
+ - **Async architecture** - built on `aiohttp` and `httpx` for high performance
12
+ - **Type safety** - uses `pydantic` for data validation
13
+ - **Simple API** - intuitive interface for working with data
14
+ - **Full-featured** - access to marks, homeworks, events, and profile data
15
+
16
+ ## 📋 Requirements
17
+
18
+ - Python 3.12+
19
+ - aiohttp >= 3.12.15
20
+ - pydantic >= 2.11.9
21
+ - httpx >= 0.28.1
22
+
23
+ ## 📦 Installation
24
+
25
+ ```bash
26
+ pip install schoolmospy
27
+ ```
28
+
29
+ ## 🚀 Quick Start
30
+
31
+ ```python
32
+ import asyncio
33
+ from schoolmospy import StudentClient
34
+
35
+ async def main():
36
+ # Create client
37
+ client = StudentClient(
38
+ token="your_token",
39
+ profile_id=12345
40
+ )
41
+
42
+ # Get profile
43
+ profile = await client.get_me()
44
+ print(f"Name: {profile.name}")
45
+
46
+ # Get marks
47
+ marks = await client.marks.get_marks(
48
+ from_date="2024-01-01",
49
+ to_date="2024-12-31"
50
+ )
51
+
52
+ # Get homeworks
53
+ homeworks = await client.homeworks.get_homeworks(
54
+ from_date="2024-01-01",
55
+ to_date="2024-12-31"
56
+ )
57
+
58
+ # Get events/schedule
59
+ events = await client.events.get_events(
60
+ from_date="2024-01-01",
61
+ to_date="2024-12-31"
62
+ )
63
+
64
+ await client.close()
65
+
66
+ asyncio.run(main())
67
+ ```
68
+
69
+ ## 📝 License
70
+
71
+ This project is licensed under the GPL-3.0 License. See the [LICENSE](LICENSE) file for details.
72
+
73
+ ## 🔗 Links
74
+
75
+ - [Documentation](https://xd2dd.github.io/schoolmospy)
76
+ - [Report an Issue](https://github.com/xd2dd/schoolmospy/issues)
77
+
78
+ ## 👨‍💻 Author
79
+
80
+ Ivan Kriventsev - [xd2dd@icloud.com](mailto:xd2dd@icloud.com)
81
+
82
+ ---
83
+
84
+ ⭐ If you like this project, please give it a star on GitHub!
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "schoolmospy"
3
- version = "0.0.2"
3
+ version = "0.2.1"
4
4
  description = "A lightweight async Python wrapper for school.mos.ru APIs"
5
5
  authors = [{ name = "Ivan Kriventsev", email = "xd2dd@icloud.com" }]
6
6
  readme = "README.md"
@@ -20,6 +20,7 @@ classifiers = [
20
20
  dependencies = [
21
21
  "aiohttp >=3.12.15,<4.0.0",
22
22
  "pydantic >=2.11.9,<3.0.0",
23
+ "httpx (>=0.28.1,<0.29.0)",
23
24
  ]
24
25
 
25
26
  packages = [{ include = "schoolmospy" }]
@@ -33,16 +33,15 @@ class BasicClient:
33
33
  headers["Profile-Id"] = str(self.profile_id)
34
34
  if self.profile_type:
35
35
  headers["Profile-Type"] = self.profile_type
36
+ headers["X-Mes-Role"] = self.profile_type
36
37
  return headers
37
38
 
38
39
  async def _handle_response(self, response: httpx.Response, response_model: Optional[Type[BaseModel]] = None):
39
- """Обработка ответа и ошибок"""
40
40
  if response.is_success:
41
41
  if response_model:
42
42
  return response_model.model_validate(response.json())
43
43
  return response.json()
44
44
 
45
- # Ошибки
46
45
  text = response.text.strip()
47
46
  status = response.status_code
48
47
 
@@ -0,0 +1,62 @@
1
+ from datetime import datetime
2
+ from schoolmospy.core.basic_client import BasicClient
3
+ from schoolmospy.models.events import Events
4
+
5
+
6
+ class EventClient:
7
+ def __init__(self, client: BasicClient):
8
+ """
9
+ Initialization the EventClient instance.
10
+
11
+ Args:
12
+ client (BasicClient): An instance of BasicClient or any compatible subclass,
13
+ used for making API requests.
14
+ """
15
+ self.client = client
16
+
17
+ async def get(self, from_date: datetime, to_date: datetime, contingent_guid: str = None) -> Events:
18
+ """
19
+ Method for getting events done within a certain period of time
20
+
21
+ Args:
22
+ from_date (datetime): The start date of the period (inclusive).
23
+ to_date (datetime): The end date of the period (inclusive).
24
+ contingent_guid (str): Person ID
25
+
26
+ Returns:
27
+ Events: A Pydantic model containing a list of events items.
28
+
29
+ Raises:
30
+ APIError: If the request fails or returns an unexpected response.
31
+ AuthError: If the provided token is invalid or expired.
32
+
33
+ Example:
34
+ ```python
35
+ from datetime import datetime
36
+ from schoolmospy.clients.student_client import StudentClient
37
+
38
+ client = StudentClient(token="YOUR_TOKEN", profile_id=17234613)
39
+
40
+ me = await client.get_me()
41
+
42
+ events = await client.events.get(
43
+ from_date=datetime(2025, 10, 1),
44
+ to_date=datetime(2025, 10, 24),
45
+ contingent_guid=me.contingent_guid
46
+ )
47
+ print(events.response)
48
+ ```
49
+ """
50
+
51
+
52
+ return await self.client.get(
53
+ "/api/eventcalendar/v1/api/events",
54
+ Events,
55
+ params={
56
+ "from": from_date.strftime("%Y-%m-%d"),
57
+ "to": to_date.strftime("%Y-%m-%d"),
58
+ "person_ids": contingent_guid,
59
+ "expand": "marks,homework,absence_reason_id,health_status,nonattendance_reason_id",
60
+ "source_types": "PLAN,AE,EC,EVENTS,AFISHA,ORGANIZER,OLYMPIAD,PROF"
61
+ }
62
+ )
@@ -4,6 +4,7 @@ from schoolmospy.models.profile import Profile
4
4
  from schoolmospy.models.userinfo import Userinfo
5
5
  from schoolmospy.core.homeworks_client import HomeworkClient
6
6
  from schoolmospy.core.marks_client import MarksClient
7
+ from schoolmospy.core.events_client import EventClient
7
8
 
8
9
 
9
10
  class StudentClient(BasicClient):
@@ -16,15 +17,28 @@ class StudentClient(BasicClient):
16
17
  super().__init__(base_url, token, profile_id, profile_type, timeout)
17
18
  self.homeworks = HomeworkClient(self)
18
19
  self.marks = MarksClient(self)
20
+ self.events = EventClient(self)
19
21
 
20
22
 
21
23
  async def get_me(self) -> Profile:
24
+ """
25
+ Get the current user's profile information.
26
+
27
+ Returns:
28
+ Profile: Profile object containing user data
29
+ """
22
30
  return await self.get(
23
31
  "/api/family/web/v1/profile",
24
32
  Profile,
25
33
  )
26
-
34
+
27
35
  async def userinfo(self) -> Userinfo:
36
+ """
37
+ Get basic user information from OAuth.
38
+
39
+ Returns:
40
+ Userinfo: Object with basic user information
41
+ """
28
42
  return await self.get(
29
43
  "/v1/oauth/userinfo",
30
44
  Userinfo
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import Any, List, Optional
4
+
5
+ from pydantic import BaseModel
6
+
7
+
8
+ class EventItem(BaseModel):
9
+ id: int
10
+ source_id: str
11
+ source: str
12
+ start_at: str
13
+ finish_at: str
14
+ cancelled: Optional[bool] = None
15
+ lesson_type: Optional[str] = None
16
+ course_lesson_type: Optional[Any] = None
17
+ lesson_form: Optional[Any] = None
18
+ replaced: Optional[bool] = None
19
+ room_name: Optional[str]
20
+ room_number: Optional[str]
21
+ subject_id: Optional[int] = None
22
+ subject_name: str
23
+ link_to_join: Optional[Any] = None
24
+ health_status: Any
25
+ absence_reason_id: Any
26
+ nonattendance_reason_id: Any
27
+ homework: Optional[Any] = None
28
+ marks: Optional[Any] = None
29
+ is_missed_lesson: bool
30
+ esz_field_id: Optional[int] = None
31
+ lesson_theme: Optional[Any] = None
32
+
33
+
34
+ class Events(BaseModel):
35
+ total_count: int
36
+ response: List[EventItem]
37
+ errors: Any
@@ -24,7 +24,7 @@ class Material(BaseModel):
24
24
  action_name: str
25
25
 
26
26
 
27
- class PayloadItem(BaseModel):
27
+ class HomeworkItem(BaseModel):
28
28
  type: str
29
29
  description: str
30
30
  comments: List
@@ -49,4 +49,4 @@ class PayloadItem(BaseModel):
49
49
 
50
50
 
51
51
  class Homeworks(BaseModel):
52
- payload: List[PayloadItem]
52
+ payload: List[HomeworkItem]
@@ -20,7 +20,7 @@ class Value(BaseModel):
20
20
  grade_system_type: str
21
21
 
22
22
 
23
- class PayloadItem(BaseModel):
23
+ class MarkItem(BaseModel):
24
24
  id: int
25
25
  value: str
26
26
  values: List[Value]
@@ -42,4 +42,4 @@ class PayloadItem(BaseModel):
42
42
 
43
43
 
44
44
  class Marks(BaseModel):
45
- payload: List[PayloadItem]
45
+ payload: List[MarkItem]
@@ -1,28 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: schoolmospy
3
- Version: 0.0.2
4
- Summary: A lightweight async Python wrapper for school.mos.ru APIs
5
- License: GPL-3.0-only
6
- License-File: LICENSE
7
- Keywords: school,mos,api,education,async,wrapper,python
8
- Author: Ivan Kriventsev
9
- Author-email: xd2dd@icloud.com
10
- Requires-Python: >=3.12
11
- Classifier: Programming Language :: Python :: 3.12
12
- Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Intended Audience :: Developers
15
- Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
- Requires-Dist: aiohttp (>=3.12.15,<4.0.0)
17
- Requires-Dist: pydantic (>=2.11.9,<3.0.0)
18
- Project-URL: Documentation, https://xd2dd.github.io/schoolmospy
19
- Project-URL: Homepage, https://github.com/xd2dd/schoolmospy
20
- Project-URL: Issues, https://github.com/xd2dd/schoolmospy/issues
21
- Description-Content-Type: text/markdown
22
-
23
- # 📕 SchoolMosPy
24
-
25
- SchoolMosPy - a lightweight Python wrapper for school.mos.py APIs.
26
-
27
-
28
-
@@ -1,5 +0,0 @@
1
- # 📕 SchoolMosPy
2
-
3
- SchoolMosPy - a lightweight Python wrapper for school.mos.py APIs.
4
-
5
-
File without changes