esprit-py 0.3.3__py3-none-any.whl → 0.3.4__py3-none-any.whl

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.

Potentially problematic release.


This version of esprit-py might be problematic. Click here for more details.

esprit/absence.py CHANGED
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
 
4
3
 
esprit/auth.py CHANGED
@@ -114,6 +114,7 @@ class Auth:
114
114
  Login failed!
115
115
  -------------
116
116
  ''')
117
+ return None
117
118
 
118
119
 
119
120
  # Code for debugging login
esprit/credit.py CHANGED
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
 
4
3
 
esprit/esprit.py CHANGED
@@ -4,6 +4,8 @@ from .grade import Grade
4
4
  from .absence import Absence
5
5
  from .time_schedule import TimeSchedule
6
6
  from .credit import Credit
7
+ from .utils import Utils
8
+ # from .exceptions import EspritException #TODO
7
9
 
8
10
 
9
11
  class Esprit:
@@ -14,6 +16,7 @@ class Esprit:
14
16
  self.absence_scrape = Absence(self.session)
15
17
  self.time_schedule_scrape = TimeSchedule(self.session)
16
18
  self.credit = Credit(self.session)
19
+ self.utils = Utils(self.session)
17
20
 
18
21
  def login(self, username, password):
19
22
  cookies = self.auth.login(username, password)
@@ -43,3 +46,9 @@ class Esprit:
43
46
 
44
47
  def get_credits(self):
45
48
  return self.credit.get_credits()
49
+
50
+ def get_student_name(self):
51
+ return self.utils.get_student_name()
52
+
53
+ def get_student_class(self):
54
+ return self.utils.get_student_class()
esprit/grade.py CHANGED
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
  import pandas as pd
4
3
  import numpy as np
@@ -21,6 +20,8 @@ class Grade:
21
20
  -------
22
21
  get_grades():
23
22
  Returns a list of grades for the student.
23
+ calculate_average(grades):
24
+ Calculate the average grade based on the given grades.
24
25
  """
25
26
 
26
27
  def __init__(self, session):
@@ -54,6 +55,17 @@ class Grade:
54
55
  return grades
55
56
 
56
57
  def calculate_average(self, grades):
58
+ """
59
+ Calculate the average grade based on the given grades.
60
+
61
+ Parameters
62
+ ----------
63
+ grades (list): A list of lists representing the grades. The first list should contain the column names.
64
+
65
+ Returns
66
+ -------
67
+ float: The calculated average grade.
68
+ """
57
69
  # Convert the list of lists to a DataFrame
58
70
  df = pd.DataFrame(grades[1:], columns=grades[0])
59
71
 
esprit/time_schedule.py CHANGED
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
  from datetime import datetime
4
3
  import re
esprit/utils.py ADDED
@@ -0,0 +1,57 @@
1
+ from bs4 import BeautifulSoup
2
+
3
+
4
+ class Utils:
5
+ """
6
+ A utility class for interacting with the ESPRIT website.
7
+ """
8
+
9
+ def __init__(self, session):
10
+ self.url = "https://esprit-tn.com/ESPOnline/Etudiants/Accueil.aspx"
11
+ self.session = session
12
+
13
+ def get_student_name(self):
14
+ """
15
+ Get the name of the student from the ESPRIT website.
16
+
17
+ Returns:
18
+ The name of the student, or None if the name could not be found.
19
+ """
20
+ response = self.session.get(self.url)
21
+ soup = BeautifulSoup(response.text, 'html.parser')
22
+
23
+ # Check if the <p> tag with the class "lead" and the string "Vous pouvez consulter dans cet espace :" exists
24
+ p_tag = soup.find('p', class_='lead',
25
+ string='Vous pouvez consulter dans cet espace :')
26
+ if p_tag is None:
27
+ print("The page does not contain the expected text.")
28
+ return None
29
+
30
+ span = soup.find('span', {'id': 'Label2', 'class': 'h4 text-info'})
31
+ if span is not None:
32
+ return span.text.strip()
33
+ else:
34
+ return None
35
+
36
+ def get_student_class(self):
37
+ """
38
+ Get the class of the student from the ESPRIT website.
39
+
40
+ Returns:
41
+ The class of the student, or None if the class could not be found.
42
+ """
43
+ response = self.session.get(self.url)
44
+ soup = BeautifulSoup(response.text, 'html.parser')
45
+
46
+ # Check if the <p> tag with the class "lead" and the string "Vous pouvez consulter dans cet espace :" exists
47
+ p_tag = soup.find('p', class_='lead',
48
+ string='Vous pouvez consulter dans cet espace :')
49
+ if p_tag is None:
50
+ print("The page does not contain the expected text.")
51
+ return None
52
+
53
+ span = soup.find('span', {'id': 'Label3'})
54
+ if span is not None:
55
+ return span.text.strip()
56
+ else:
57
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: esprit-py
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: A Python library for interacting with data from esprit-tn.com
5
5
  Home-page: https://github.com/TheLime1/esprit.py
6
6
  Author: Lime1 (Aymen Hmani)
@@ -23,51 +23,180 @@ Requires-Dist: pandas
23
23
 
24
24
  # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
25
25
 
26
+
27
+
26
28
  > [!NOTE]
29
+
27
30
  > Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
28
31
 
32
+
33
+
29
34
  ## Features
30
35
 
36
+
37
+
31
38
  - Get your exact timetable pdf *not 300 pages pdf*
39
+
32
40
  - Get your grades
41
+
33
42
  - Get your absences
43
+
34
44
  - Get your credits
35
45
 
46
+ - Calculate your total semester average
47
+
48
+
49
+
36
50
  ## Installation
37
51
 
52
+
53
+
38
54
  ```bash
55
+
39
56
  pip install esprit-py
57
+
40
58
  ```
41
59
 
60
+
61
+
42
62
  download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
43
63
 
44
- ## Example
64
+
65
+
66
+ ## Examples
67
+
68
+
69
+
70
+ get your total avreage:
71
+
72
+
73
+
74
+ ```python
75
+
76
+ from esprit import Esprit
77
+
78
+
79
+
80
+ # Replace with your actual ID and password
81
+
82
+ id = 'ID'
83
+
84
+ password = 'PASSWORD'
85
+
86
+
87
+
88
+ grades = None
89
+
90
+
91
+
92
+ # Keep trying to get grades until it is successful cuz esprit use garabage servers
93
+
94
+ while grades is None:
95
+
96
+ try:
97
+
98
+ # Create an Esprit object
99
+
100
+ esprit = Esprit(
101
+
102
+ driver_path="C:/path/to/chromedriver.exe")
103
+
104
+
105
+
106
+ # Attempt to log in
107
+
108
+ esprit.login(id, password)
109
+
110
+
111
+
112
+ # Get grades
113
+
114
+ grades = esprit.get_grades()
115
+
116
+
117
+
118
+ except Exception as e:
119
+
120
+ print(f"An error occurred: {e}. Retrying...")
121
+
122
+
123
+
124
+ if grades is not None:
125
+
126
+ for grade in grades:
127
+
128
+ print(grade)
129
+
130
+ else:
131
+
132
+ print("Failed to get grades.")
133
+
134
+
135
+
136
+ esprit.calculate_average(grades)
137
+
138
+
139
+
140
+ ```
141
+
142
+
143
+
144
+ get a list of all your absences;
145
+
146
+
45
147
 
46
148
  ```python
149
+
47
150
  from esprit import Esprit
48
151
 
152
+
153
+
49
154
  # Create an Esprit object
155
+
50
156
  esprit = Esprit(
157
+
51
158
  driver_path="C:/path/to/chromedriver.exe",)
52
159
 
160
+
161
+
53
162
  # Replace with your actual ID and password
163
+
54
164
  id = 'ID'
165
+
55
166
  password = 'PASSWORD'
56
167
 
168
+
169
+
57
170
  # Attempt to log in
171
+
58
172
  if esprit.login(id, password):
173
+
59
174
  print("Login successful.")
175
+
60
176
  else:
177
+
61
178
  print("Login failed.")
62
179
 
180
+
181
+
63
182
  # Get absences
183
+
64
184
  absences = esprit.get_absences()
185
+
65
186
  if absences is not None:
187
+
66
188
  for absence in absences:
189
+
67
190
  print(absence)
191
+
68
192
  else:
193
+
69
194
  print("Failed to get absences.")
70
195
 
196
+
197
+
71
198
  ```
72
199
 
200
+
201
+
73
202
  More examples can be found in the [examples folder](examples)
@@ -0,0 +1,13 @@
1
+ esprit/__init__.py,sha256=PnahGRQ5xmA26XMFaj9ImLty9OEmYwnBqLanvGXZwwU,28
2
+ esprit/absence.py,sha256=1CE7FCnWUr9omNXkgFH4Q3Vq5FkonjAEOmAOarXoCqU,1649
3
+ esprit/auth.py,sha256=rT46FuRfeM3cCit5ltsLvXxN6rOUY7XEagGcJMXPVlI,4059
4
+ esprit/credit.py,sha256=G4UPVaJEFiucF4dbmwLcCl_OUD419UstPRJ3GeGj5nI,1730
5
+ esprit/esprit.py,sha256=kj46pKuyuJZuCKVxwBehKZVKycKauGYSKpMDmo3n-lw,1961
6
+ esprit/grade.py,sha256=Wt5rjcqHAaG2gQ5DaqaMUMkP7ImMhZhQqoJTxTZkXhk,3504
7
+ esprit/time_schedule.py,sha256=APash3wNe09kdwJDl3B1Du1WH71h6j3TAirVGoWndCc,6473
8
+ esprit/utils.py,sha256=evATWiuwSp80IvKV-jkjLX8kNW6tEYR4Iakr-HQu9gs,2009
9
+ esprit_py-0.3.4.dist-info/LICENSE,sha256=DOcn7qpE6TsUEcakIsDDKm757jx5YlQ8fXDiED21P_w,1089
10
+ esprit_py-0.3.4.dist-info/METADATA,sha256=cYU7wA9DFyaYz8-I8R9vkdM_vIP2xF3e8QXxCdhw0Ao,2863
11
+ esprit_py-0.3.4.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
12
+ esprit_py-0.3.4.dist-info/top_level.txt,sha256=aS9besFTZ4EYTsoBJVf3GaMjQtJLgLaK7WqAxSvGVdQ,7
13
+ esprit_py-0.3.4.dist-info/RECORD,,
@@ -1,12 +0,0 @@
1
- esprit/__init__.py,sha256=PnahGRQ5xmA26XMFaj9ImLty9OEmYwnBqLanvGXZwwU,28
2
- esprit/absence.py,sha256=qOFyK0QmSaWYrz_2RlDFcCom-m6QZLJAzG1dBj3YkbI,1666
3
- esprit/auth.py,sha256=-jkquqEGZ8I7K61T4QsXHLfDTIwdhbirOrtEmGysbqQ,4034
4
- esprit/credit.py,sha256=iKy_lTR_iLAkpRkP92l2gAUi4Dh6JvLidxGhuM9YJ68,1747
5
- esprit/esprit.py,sha256=xjXqkXIGgV5J0DGSwBIM-ihj7123SH7DASzHPL0Fzpg,1680
6
- esprit/grade.py,sha256=ip30Aavx9mCdwIpziXLENLMaEmaIM6mkC3EXnT0041g,3098
7
- esprit/time_schedule.py,sha256=sU2gwV9dmIyFhSe0qlxTGg05L7lhLbD0YN0qhMXdNc0,6490
8
- esprit_py-0.3.3.dist-info/LICENSE,sha256=DOcn7qpE6TsUEcakIsDDKm757jx5YlQ8fXDiED21P_w,1089
9
- esprit_py-0.3.3.dist-info/METADATA,sha256=TfDmCND5Di6lTJHWIf8-MaalKcTQ0veV3g1gbEaJPnM,1833
10
- esprit_py-0.3.3.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
11
- esprit_py-0.3.3.dist-info/top_level.txt,sha256=aS9besFTZ4EYTsoBJVf3GaMjQtJLgLaK7WqAxSvGVdQ,7
12
- esprit_py-0.3.3.dist-info/RECORD,,