schoolapp-api 2.1.2__tar.gz → 2.1.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.
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/LICENSE +21 -21
- {schoolapp_api-2.1.2/schoolapp_api.egg-info → schoolapp_api-2.1.3}/PKG-INFO +62 -62
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/README.md +50 -50
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/pyproject.toml +20 -21
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/__init__.py +10 -10
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/auth.py +95 -95
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/constants.py +38 -38
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/http_client.py +79 -79
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/__init__.py +11 -11
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/attendance_manager.py +15 -15
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/base_manager.py +36 -36
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/course_manager.py +45 -45
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/grades_manager.py +35 -35
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/managers/profile_manager.py +15 -15
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/__init__.py +6 -6
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/absences.py +44 -44
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/annees.py +36 -36
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/filieres.py +62 -62
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/modules.py +55 -55
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/note_elem.py +32 -32
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/note_mod.py +32 -32
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/profile.py +86 -86
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/sanctions.py +41 -41
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/parsers/semestres.py +36 -36
- schoolapp_api-2.1.3/schoolapp_api/parsers/stats.py +45 -0
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/school_app_client.py +63 -63
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/__init__.py +9 -9
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/annee.py +22 -22
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/base.py +34 -34
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/element.py +42 -42
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/module.py +21 -21
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api/types/semestre.py +23 -23
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3/schoolapp_api.egg-info}/PKG-INFO +62 -62
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/setup.cfg +4 -4
- schoolapp_api-2.1.2/schoolapp_api/parsers/stats.py +0 -34
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api.egg-info/SOURCES.txt +0 -0
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api.egg-info/dependency_links.txt +0 -0
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api.egg-info/requires.txt +0 -0
- {schoolapp_api-2.1.2 → schoolapp_api-2.1.3}/schoolapp_api.egg-info/top_level.txt +0 -0
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) [2026] [Aferiad Kamal]
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) [2026] [Aferiad Kamal]
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: schoolapp-api
|
|
3
|
-
Version: 2.1.
|
|
4
|
-
Summary: Professional client for interacting with the School App API
|
|
5
|
-
Author: Aferiad Kamal
|
|
6
|
-
License: MIT
|
|
7
|
-
Requires-Python: >=3.7
|
|
8
|
-
Description-Content-Type: text/markdown
|
|
9
|
-
License-File: LICENSE
|
|
10
|
-
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
-
Dynamic: license-file
|
|
12
|
-
|
|
13
|
-
# SchoolApp API
|
|
14
|
-
|
|
15
|
-
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
16
|
-
|
|
17
|
-
## Why This Exists
|
|
18
|
-
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
19
|
-
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
20
|
-
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
21
|
-
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
22
|
-
|
|
23
|
-
## Quick Start
|
|
24
|
-
|
|
25
|
-
### Installation
|
|
26
|
-
You can install the library locally using:
|
|
27
|
-
```bash
|
|
28
|
-
pip install schoolapp-api
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Basic Usage
|
|
32
|
-
Getting your data is as simple as this:
|
|
33
|
-
|
|
34
|
-
```python
|
|
35
|
-
from schoolapp_api import SchoolAppClient
|
|
36
|
-
|
|
37
|
-
# Initialize and log in
|
|
38
|
-
client = SchoolAppClient()
|
|
39
|
-
if client.login("your.email@example.com", "password"):
|
|
40
|
-
|
|
41
|
-
# Get your basic info
|
|
42
|
-
profile = client.get_profile()
|
|
43
|
-
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
44
|
-
|
|
45
|
-
# Fetch your current semester grades
|
|
46
|
-
grades = client.get_current_elem_note()
|
|
47
|
-
for item in grades:
|
|
48
|
-
print(f"{item.CodeElem}: {item.Moy}")
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Project Layout
|
|
52
|
-
The library is organized into several specific managers, so you always know where to find what you need:
|
|
53
|
-
|
|
54
|
-
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
55
|
-
- **`attendance`**: Track your absences and see any sanctions.
|
|
56
|
-
- **`profile`**: Access your personal data and administrative files.
|
|
57
|
-
- **`courses`**: Browse the study plan and available modules.
|
|
58
|
-
|
|
59
|
-
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
60
|
-
|
|
61
|
-
## Contributions
|
|
62
|
-
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: schoolapp-api
|
|
3
|
+
Version: 2.1.3
|
|
4
|
+
Summary: Professional client for interacting with the School App API
|
|
5
|
+
Author: Aferiad Kamal
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.7
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: beautifulsoup4>=4.9.0
|
|
11
|
+
Dynamic: license-file
|
|
12
|
+
|
|
13
|
+
# SchoolApp API
|
|
14
|
+
|
|
15
|
+
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
16
|
+
|
|
17
|
+
## Why This Exists
|
|
18
|
+
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
19
|
+
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
20
|
+
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
21
|
+
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
22
|
+
|
|
23
|
+
## Quick Start
|
|
24
|
+
|
|
25
|
+
### Installation
|
|
26
|
+
You can install the library locally using:
|
|
27
|
+
```bash
|
|
28
|
+
pip install schoolapp-api
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Basic Usage
|
|
32
|
+
Getting your data is as simple as this:
|
|
33
|
+
|
|
34
|
+
```python
|
|
35
|
+
from schoolapp_api import SchoolAppClient
|
|
36
|
+
|
|
37
|
+
# Initialize and log in
|
|
38
|
+
client = SchoolAppClient()
|
|
39
|
+
if client.login("your.email@example.com", "password"):
|
|
40
|
+
|
|
41
|
+
# Get your basic info
|
|
42
|
+
profile = client.get_profile()
|
|
43
|
+
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
44
|
+
|
|
45
|
+
# Fetch your current semester grades
|
|
46
|
+
grades = client.get_current_elem_note()
|
|
47
|
+
for item in grades:
|
|
48
|
+
print(f"{item.CodeElem}: {item.Moy}")
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Project Layout
|
|
52
|
+
The library is organized into several specific managers, so you always know where to find what you need:
|
|
53
|
+
|
|
54
|
+
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
55
|
+
- **`attendance`**: Track your absences and see any sanctions.
|
|
56
|
+
- **`profile`**: Access your personal data and administrative files.
|
|
57
|
+
- **`courses`**: Browse the study plan and available modules.
|
|
58
|
+
|
|
59
|
+
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
60
|
+
|
|
61
|
+
## Contributions
|
|
62
|
+
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
# SchoolApp API
|
|
2
|
-
|
|
3
|
-
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
4
|
-
|
|
5
|
-
## Why This Exists
|
|
6
|
-
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
7
|
-
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
8
|
-
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
9
|
-
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
10
|
-
|
|
11
|
-
## Quick Start
|
|
12
|
-
|
|
13
|
-
### Installation
|
|
14
|
-
You can install the library locally using:
|
|
15
|
-
```bash
|
|
16
|
-
pip install schoolapp-api
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
### Basic Usage
|
|
20
|
-
Getting your data is as simple as this:
|
|
21
|
-
|
|
22
|
-
```python
|
|
23
|
-
from schoolapp_api import SchoolAppClient
|
|
24
|
-
|
|
25
|
-
# Initialize and log in
|
|
26
|
-
client = SchoolAppClient()
|
|
27
|
-
if client.login("your.email@example.com", "password"):
|
|
28
|
-
|
|
29
|
-
# Get your basic info
|
|
30
|
-
profile = client.get_profile()
|
|
31
|
-
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
32
|
-
|
|
33
|
-
# Fetch your current semester grades
|
|
34
|
-
grades = client.get_current_elem_note()
|
|
35
|
-
for item in grades:
|
|
36
|
-
print(f"{item.CodeElem}: {item.Moy}")
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
## Project Layout
|
|
40
|
-
The library is organized into several specific managers, so you always know where to find what you need:
|
|
41
|
-
|
|
42
|
-
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
43
|
-
- **`attendance`**: Track your absences and see any sanctions.
|
|
44
|
-
- **`profile`**: Access your personal data and administrative files.
|
|
45
|
-
- **`courses`**: Browse the study plan and available modules.
|
|
46
|
-
|
|
47
|
-
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
48
|
-
|
|
49
|
-
## Contributions
|
|
50
|
-
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
1
|
+
# SchoolApp API
|
|
2
|
+
|
|
3
|
+
A Python library designed to make interacting with the SchoolApp platform a lot less painful. Instead of wrestling with session cookies and manual HTML scraping, this library gives you a clean, object-oriented way to access your grades, attendance, and profile data.
|
|
4
|
+
|
|
5
|
+
## Why This Exists
|
|
6
|
+
Browsing the SchoolApp web interface manually for updates is slow. If you want to build a custom dashboard, a grade tracker, or a notification bot, you need a reliable way to get that data programmatically. This library takes care of:
|
|
7
|
+
- **Authentication**: Solid session management with automatic CSRF token handling.
|
|
8
|
+
- **Data Cleanup**: Converts messy HTML tables into structured Python objects.
|
|
9
|
+
- **Smart Logic**: Handles nested modules, element-level statistics, and transcript parsing out of the box.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
### Installation
|
|
14
|
+
You can install the library locally using:
|
|
15
|
+
```bash
|
|
16
|
+
pip install schoolapp-api
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
### Basic Usage
|
|
20
|
+
Getting your data is as simple as this:
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from schoolapp_api import SchoolAppClient
|
|
24
|
+
|
|
25
|
+
# Initialize and log in
|
|
26
|
+
client = SchoolAppClient()
|
|
27
|
+
if client.login("your.email@example.com", "password"):
|
|
28
|
+
|
|
29
|
+
# Get your basic info
|
|
30
|
+
profile = client.get_profile()
|
|
31
|
+
print(f"Hello, {profile['basic_info']['full_name']}!")
|
|
32
|
+
|
|
33
|
+
# Fetch your current semester grades
|
|
34
|
+
grades = client.get_current_elem_note()
|
|
35
|
+
for item in grades:
|
|
36
|
+
print(f"{item.CodeElem}: {item.Moy}")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Project Layout
|
|
40
|
+
The library is organized into several specific managers, so you always know where to find what you need:
|
|
41
|
+
|
|
42
|
+
- **`grades`**: Handle module marks, element notes, and academic year results.
|
|
43
|
+
- **`attendance`**: Track your absences and see any sanctions.
|
|
44
|
+
- **`profile`**: Access your personal data and administrative files.
|
|
45
|
+
- **`courses`**: Browse the study plan and available modules.
|
|
46
|
+
|
|
47
|
+
For the full details on every class and function, head over to the [**/docs**](./docs/README.md) folder.
|
|
48
|
+
|
|
49
|
+
## Contributions
|
|
50
|
+
Found a bug or have an idea for a new feature? Feel free to open an issue or submit a pull request. Any help making this library better for everyone is appreciated!
|
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
[build-system]
|
|
2
|
-
requires = ["setuptools>=61.0"]
|
|
3
|
-
build-backend = "setuptools.build_meta"
|
|
4
|
-
|
|
5
|
-
[project]
|
|
6
|
-
name = "schoolapp-api"
|
|
7
|
-
version = "2.1.
|
|
8
|
-
description = "Professional client for interacting with the School App API"
|
|
9
|
-
readme = "README.md"
|
|
10
|
-
requires-python = ">=3.7"
|
|
11
|
-
license = {text = "MIT"}
|
|
12
|
-
authors = [
|
|
13
|
-
{name = "Aferiad Kamal"}
|
|
14
|
-
]
|
|
15
|
-
dependencies = [
|
|
16
|
-
"beautifulsoup4>=4.9.0",
|
|
17
|
-
]
|
|
18
|
-
|
|
19
|
-
[tool.setuptools]
|
|
20
|
-
packages = ["schoolapp_api", "schoolapp_api.managers", "schoolapp_api.parsers", "schoolapp_api.types"]
|
|
21
|
-
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "schoolapp-api"
|
|
7
|
+
version = "2.1.3"
|
|
8
|
+
description = "Professional client for interacting with the School App API"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.7"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Aferiad Kamal"}
|
|
14
|
+
]
|
|
15
|
+
dependencies = [
|
|
16
|
+
"beautifulsoup4>=4.9.0",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools]
|
|
20
|
+
packages = ["schoolapp_api", "schoolapp_api.managers", "schoolapp_api.parsers", "schoolapp_api.types"]
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Professional School App API Client
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
from .school_app_client import SchoolAppClient
|
|
6
|
-
from .http_client import HTTPClient
|
|
7
|
-
from .auth import AuthManager
|
|
8
|
-
|
|
9
|
-
__version__ = "2.
|
|
10
|
-
__all__ = ["SchoolAppClient", "HTTPClient", "AuthManager"]
|
|
1
|
+
"""
|
|
2
|
+
Professional School App API Client
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from .school_app_client import SchoolAppClient
|
|
6
|
+
from .http_client import HTTPClient
|
|
7
|
+
from .auth import AuthManager
|
|
8
|
+
|
|
9
|
+
__version__ = "2.0.0"
|
|
10
|
+
__all__ = ["SchoolAppClient", "HTTPClient", "AuthManager"]
|
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Authentication and CSRF token management
|
|
3
|
-
"""
|
|
4
|
-
import re
|
|
5
|
-
import logging
|
|
6
|
-
from schoolapp_api.constants import LOGIN_URL
|
|
7
|
-
|
|
8
|
-
logger = logging.getLogger(__name__)
|
|
9
|
-
|
|
10
|
-
class AuthManager:
|
|
11
|
-
"""Handles authentication and CSRF token management"""
|
|
12
|
-
|
|
13
|
-
def __init__(self, http_client, base_url):
|
|
14
|
-
self.http_client = http_client
|
|
15
|
-
self.base_url = base_url
|
|
16
|
-
self.login_url = LOGIN_URL
|
|
17
|
-
self.csrf_token = None
|
|
18
|
-
self.logged_in = False
|
|
19
|
-
|
|
20
|
-
@staticmethod
|
|
21
|
-
def extract_csrf_token(html_content):
|
|
22
|
-
"""Extract CSRF token from HTML content"""
|
|
23
|
-
match = re.search(r'name=["\']_csrf["\']\s+value=["\']([^"\']+)["\']', html_content)
|
|
24
|
-
return match.group(1) if match else None
|
|
25
|
-
|
|
26
|
-
def update_csrf_token(self, html_content):
|
|
27
|
-
"""Update CSRF token from HTML content"""
|
|
28
|
-
new_csrf = self.extract_csrf_token(html_content)
|
|
29
|
-
if new_csrf:
|
|
30
|
-
self.csrf_token = new_csrf
|
|
31
|
-
return True
|
|
32
|
-
return False
|
|
33
|
-
|
|
34
|
-
def login(self, email, password):
|
|
35
|
-
"""Login and maintain session"""
|
|
36
|
-
if self.logged_in:
|
|
37
|
-
logger.info("Already logged in!")
|
|
38
|
-
return True
|
|
39
|
-
|
|
40
|
-
logger.info("Fetching login page...")
|
|
41
|
-
code, url, content = self.http_client.get(self.login_url)
|
|
42
|
-
|
|
43
|
-
if not content or not self.update_csrf_token(content):
|
|
44
|
-
logger.error("Failed to fetch login page or retrieve CSRF token.")
|
|
45
|
-
return False
|
|
46
|
-
|
|
47
|
-
logger.info(f"Got CSRF token, logging in...")
|
|
48
|
-
login_data = {
|
|
49
|
-
'_csrf': self.csrf_token,
|
|
50
|
-
'email': email,
|
|
51
|
-
'password': password
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
code, response_url, content = self.http_client.post(
|
|
55
|
-
self.login_url,
|
|
56
|
-
login_data,
|
|
57
|
-
referer=self.login_url
|
|
58
|
-
)
|
|
59
|
-
|
|
60
|
-
if response_url and ("/login" in response_url and "error" in response_url):
|
|
61
|
-
logger.error("Login failed! Invalid credentials.")
|
|
62
|
-
return False
|
|
63
|
-
|
|
64
|
-
logger.info("Login successful!")
|
|
65
|
-
self.logged_in = True
|
|
66
|
-
return True
|
|
67
|
-
|
|
68
|
-
def is_logged_in(self):
|
|
69
|
-
"""Check if currently logged in"""
|
|
70
|
-
return self.logged_in
|
|
71
|
-
|
|
72
|
-
def check_session(self):
|
|
73
|
-
"""
|
|
74
|
-
Confirm whether the session is still valid.
|
|
75
|
-
"""
|
|
76
|
-
code, url, content = self.http_client.get(self.login_url)
|
|
77
|
-
|
|
78
|
-
# If server redirects us back to login, session is dead
|
|
79
|
-
if url and "/login" in url:
|
|
80
|
-
self.logged_in = False
|
|
81
|
-
return False
|
|
82
|
-
|
|
83
|
-
self.logged_in = True
|
|
84
|
-
return True
|
|
85
|
-
|
|
86
|
-
def refresh_csrf_from_url(self, url):
|
|
87
|
-
"""Fetch a fresh CSRF token from a specific page"""
|
|
88
|
-
try:
|
|
89
|
-
code, response_url, content = self.http_client.get(url)
|
|
90
|
-
if content and self.update_csrf_token(content):
|
|
91
|
-
return True
|
|
92
|
-
return False
|
|
93
|
-
except Exception as e:
|
|
94
|
-
logger.warning(f"CSRF refresh warning: {e}")
|
|
95
|
-
return False
|
|
1
|
+
"""
|
|
2
|
+
Authentication and CSRF token management
|
|
3
|
+
"""
|
|
4
|
+
import re
|
|
5
|
+
import logging
|
|
6
|
+
from schoolapp_api.constants import LOGIN_URL
|
|
7
|
+
|
|
8
|
+
logger = logging.getLogger(__name__)
|
|
9
|
+
|
|
10
|
+
class AuthManager:
|
|
11
|
+
"""Handles authentication and CSRF token management"""
|
|
12
|
+
|
|
13
|
+
def __init__(self, http_client, base_url):
|
|
14
|
+
self.http_client = http_client
|
|
15
|
+
self.base_url = base_url
|
|
16
|
+
self.login_url = LOGIN_URL
|
|
17
|
+
self.csrf_token = None
|
|
18
|
+
self.logged_in = False
|
|
19
|
+
|
|
20
|
+
@staticmethod
|
|
21
|
+
def extract_csrf_token(html_content):
|
|
22
|
+
"""Extract CSRF token from HTML content"""
|
|
23
|
+
match = re.search(r'name=["\']_csrf["\']\s+value=["\']([^"\']+)["\']', html_content)
|
|
24
|
+
return match.group(1) if match else None
|
|
25
|
+
|
|
26
|
+
def update_csrf_token(self, html_content):
|
|
27
|
+
"""Update CSRF token from HTML content"""
|
|
28
|
+
new_csrf = self.extract_csrf_token(html_content)
|
|
29
|
+
if new_csrf:
|
|
30
|
+
self.csrf_token = new_csrf
|
|
31
|
+
return True
|
|
32
|
+
return False
|
|
33
|
+
|
|
34
|
+
def login(self, email, password):
|
|
35
|
+
"""Login and maintain session"""
|
|
36
|
+
if self.logged_in:
|
|
37
|
+
logger.info("Already logged in!")
|
|
38
|
+
return True
|
|
39
|
+
|
|
40
|
+
logger.info("Fetching login page...")
|
|
41
|
+
code, url, content = self.http_client.get(self.login_url)
|
|
42
|
+
|
|
43
|
+
if not content or not self.update_csrf_token(content):
|
|
44
|
+
logger.error("Failed to fetch login page or retrieve CSRF token.")
|
|
45
|
+
return False
|
|
46
|
+
|
|
47
|
+
logger.info(f"Got CSRF token, logging in...")
|
|
48
|
+
login_data = {
|
|
49
|
+
'_csrf': self.csrf_token,
|
|
50
|
+
'email': email,
|
|
51
|
+
'password': password
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
code, response_url, content = self.http_client.post(
|
|
55
|
+
self.login_url,
|
|
56
|
+
login_data,
|
|
57
|
+
referer=self.login_url
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
if response_url and ("/login" in response_url and "error" in response_url):
|
|
61
|
+
logger.error("Login failed! Invalid credentials.")
|
|
62
|
+
return False
|
|
63
|
+
|
|
64
|
+
logger.info("Login successful!")
|
|
65
|
+
self.logged_in = True
|
|
66
|
+
return True
|
|
67
|
+
|
|
68
|
+
def is_logged_in(self):
|
|
69
|
+
"""Check if currently logged in"""
|
|
70
|
+
return self.logged_in
|
|
71
|
+
|
|
72
|
+
def check_session(self):
|
|
73
|
+
"""
|
|
74
|
+
Confirm whether the session is still valid.
|
|
75
|
+
"""
|
|
76
|
+
code, url, content = self.http_client.get(self.login_url)
|
|
77
|
+
|
|
78
|
+
# If server redirects us back to login, session is dead
|
|
79
|
+
if url and "/login" in url:
|
|
80
|
+
self.logged_in = False
|
|
81
|
+
return False
|
|
82
|
+
|
|
83
|
+
self.logged_in = True
|
|
84
|
+
return True
|
|
85
|
+
|
|
86
|
+
def refresh_csrf_from_url(self, url):
|
|
87
|
+
"""Fetch a fresh CSRF token from a specific page"""
|
|
88
|
+
try:
|
|
89
|
+
code, response_url, content = self.http_client.get(url)
|
|
90
|
+
if content and self.update_csrf_token(content):
|
|
91
|
+
return True
|
|
92
|
+
return False
|
|
93
|
+
except Exception as e:
|
|
94
|
+
logger.warning(f"CSRF refresh warning: {e}")
|
|
95
|
+
return False
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Centralized constants for the School App API
|
|
3
|
-
"""
|
|
4
|
-
|
|
5
|
-
BASE_URL = "https://schoolapp.ensam-umi.ac.ma"
|
|
6
|
-
|
|
7
|
-
# Endpoints
|
|
8
|
-
LOGIN_URL = f"{BASE_URL}/login"
|
|
9
|
-
INDEX_URL = f"{BASE_URL}/index"
|
|
10
|
-
MODULES_URL = f"{BASE_URL}/plan-etudes-view/modules"
|
|
11
|
-
FILIERES_URL = f"{BASE_URL}/plan-etudes-view/filieres"
|
|
12
|
-
|
|
13
|
-
# Student Grade Endpoints
|
|
14
|
-
CURRENT_ELEM_URL = f"{BASE_URL}/student/noteselem-encours"
|
|
15
|
-
CURRENT_MOD_URL = f"{BASE_URL}/student/notesmod-encours"
|
|
16
|
-
ELEM_URL = f"{BASE_URL}/student/noteselem"
|
|
17
|
-
MOD_URL = f"{BASE_URL}/student/notesmod"
|
|
18
|
-
ANNEES_URL = f"{BASE_URL}/student/notesannee"
|
|
19
|
-
SEMESTRES_URL = f"{BASE_URL}/student/notessem"
|
|
20
|
-
|
|
21
|
-
# Absence and Sanctions Endpoints
|
|
22
|
-
ABSENCES_URL = f"{BASE_URL}/student/absence/bilan"
|
|
23
|
-
SANCTIONS_URL = f"{BASE_URL}/student/absence/sanctions"
|
|
24
|
-
|
|
25
|
-
# Stats Endpoints
|
|
26
|
-
EVAL_STAT_URL = f"{BASE_URL}/notes-stat/elemevalsat"
|
|
27
|
-
MOD_STAT_URL = f"{BASE_URL}/notes-stat/modsat"
|
|
28
|
-
ANNEE_STAT_URL = f"{BASE_URL}/notes-stat/anneesat"
|
|
29
|
-
SEM_STAT_URL = f"{BASE_URL}/notes-stat/semsat"
|
|
30
|
-
|
|
31
|
-
# Default Headers
|
|
32
|
-
DEFAULT_HEADERS = {
|
|
33
|
-
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
34
|
-
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
35
|
-
'Accept-Language': 'en-US,en;q=0.9,fr;q=0.8',
|
|
36
|
-
'Connection': 'keep-alive',
|
|
37
|
-
'Upgrade-Insecure-Requests': '1'
|
|
38
|
-
}
|
|
1
|
+
"""
|
|
2
|
+
Centralized constants for the School App API
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
BASE_URL = "https://schoolapp.ensam-umi.ac.ma"
|
|
6
|
+
|
|
7
|
+
# Endpoints
|
|
8
|
+
LOGIN_URL = f"{BASE_URL}/login"
|
|
9
|
+
INDEX_URL = f"{BASE_URL}/index"
|
|
10
|
+
MODULES_URL = f"{BASE_URL}/plan-etudes-view/modules"
|
|
11
|
+
FILIERES_URL = f"{BASE_URL}/plan-etudes-view/filieres"
|
|
12
|
+
|
|
13
|
+
# Student Grade Endpoints
|
|
14
|
+
CURRENT_ELEM_URL = f"{BASE_URL}/student/noteselem-encours"
|
|
15
|
+
CURRENT_MOD_URL = f"{BASE_URL}/student/notesmod-encours"
|
|
16
|
+
ELEM_URL = f"{BASE_URL}/student/noteselem"
|
|
17
|
+
MOD_URL = f"{BASE_URL}/student/notesmod"
|
|
18
|
+
ANNEES_URL = f"{BASE_URL}/student/notesannee"
|
|
19
|
+
SEMESTRES_URL = f"{BASE_URL}/student/notessem"
|
|
20
|
+
|
|
21
|
+
# Absence and Sanctions Endpoints
|
|
22
|
+
ABSENCES_URL = f"{BASE_URL}/student/absence/bilan"
|
|
23
|
+
SANCTIONS_URL = f"{BASE_URL}/student/absence/sanctions"
|
|
24
|
+
|
|
25
|
+
# Stats Endpoints
|
|
26
|
+
EVAL_STAT_URL = f"{BASE_URL}/notes-stat/elemevalsat"
|
|
27
|
+
MOD_STAT_URL = f"{BASE_URL}/notes-stat/modsat"
|
|
28
|
+
ANNEE_STAT_URL = f"{BASE_URL}/notes-stat/anneesat"
|
|
29
|
+
SEM_STAT_URL = f"{BASE_URL}/notes-stat/semsat"
|
|
30
|
+
|
|
31
|
+
# Default Headers
|
|
32
|
+
DEFAULT_HEADERS = {
|
|
33
|
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
|
|
34
|
+
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
|
35
|
+
'Accept-Language': 'en-US,en;q=0.9,fr;q=0.8',
|
|
36
|
+
'Connection': 'keep-alive',
|
|
37
|
+
'Upgrade-Insecure-Requests': '1'
|
|
38
|
+
}
|