esprit-py 0.3.3__tar.gz → 0.3.4__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.

Potentially problematic release.


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

@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.1
2
+ Name: esprit-py
3
+ Version: 0.3.4
4
+ Summary: A Python library for interacting with data from esprit-tn.com
5
+ Home-page: https://github.com/TheLime1/esprit.py
6
+ Author: Lime1 (Aymen Hmani)
7
+ Keywords: python,api
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+
17
+
18
+ # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
19
+
20
+ > [!NOTE]
21
+ > Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
22
+
23
+ ## Features
24
+
25
+ - Get your exact timetable pdf *not 300 pages pdf*
26
+ - Get your grades
27
+ - Get your absences
28
+ - Get your credits
29
+ - Calculate your total semester average
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install esprit-py
35
+ ```
36
+
37
+ download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
38
+
39
+ ## Examples
40
+
41
+ get your total avreage:
42
+
43
+ ```python
44
+ from esprit import Esprit
45
+
46
+ # Replace with your actual ID and password
47
+ id = 'ID'
48
+ password = 'PASSWORD'
49
+
50
+ grades = None
51
+
52
+ # Keep trying to get grades until it is successful cuz esprit use garabage servers
53
+ while grades is None:
54
+ try:
55
+ # Create an Esprit object
56
+ esprit = Esprit(
57
+ driver_path="C:/path/to/chromedriver.exe")
58
+
59
+ # Attempt to log in
60
+ esprit.login(id, password)
61
+
62
+ # Get grades
63
+ grades = esprit.get_grades()
64
+
65
+ except Exception as e:
66
+ print(f"An error occurred: {e}. Retrying...")
67
+
68
+ if grades is not None:
69
+ for grade in grades:
70
+ print(grade)
71
+ else:
72
+ print("Failed to get grades.")
73
+
74
+ esprit.calculate_average(grades)
75
+
76
+ ```
77
+
78
+ get a list of all your absences;
79
+
80
+ ```python
81
+ from esprit import Esprit
82
+
83
+ # Create an Esprit object
84
+ esprit = Esprit(
85
+ driver_path="C:/path/to/chromedriver.exe",)
86
+
87
+ # Replace with your actual ID and password
88
+ id = 'ID'
89
+ password = 'PASSWORD'
90
+
91
+ # Attempt to log in
92
+ if esprit.login(id, password):
93
+ print("Login successful.")
94
+ else:
95
+ print("Login failed.")
96
+
97
+ # Get absences
98
+ absences = esprit.get_absences()
99
+ if absences is not None:
100
+ for absence in absences:
101
+ print(absence)
102
+ else:
103
+ print("Failed to get absences.")
104
+
105
+ ```
106
+
107
+ More examples can be found in the [examples folder](examples)
@@ -1,20 +1,3 @@
1
- Metadata-Version: 2.1
2
- Name: esprit-py
3
- Version: 0.3.3
4
- Summary: A Python library for interacting with data from esprit-tn.com
5
- Home-page: https://github.com/TheLime1/esprit.py
6
- Author: Lime1 (Aymen Hmani)
7
- Keywords: python,api
8
- Classifier: Development Status :: 1 - Planning
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: Unix
12
- Classifier: Operating System :: MacOS :: MacOS X
13
- Classifier: Operating System :: Microsoft :: Windows
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
-
17
-
18
1
  # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
19
2
 
20
3
  > [!NOTE]
@@ -26,6 +9,7 @@ License-File: LICENSE
26
9
  - Get your grades
27
10
  - Get your absences
28
11
  - Get your credits
12
+ - Calculate your total semester average
29
13
 
30
14
  ## Installation
31
15
 
@@ -35,7 +19,46 @@ pip install esprit-py
35
19
 
36
20
  download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
37
21
 
38
- ## Example
22
+ ## Examples
23
+
24
+ get your total avreage:
25
+
26
+ ```python
27
+ from esprit import Esprit
28
+
29
+ # Replace with your actual ID and password
30
+ id = 'ID'
31
+ password = 'PASSWORD'
32
+
33
+ grades = None
34
+
35
+ # Keep trying to get grades until it is successful cuz esprit use garabage servers
36
+ while grades is None:
37
+ try:
38
+ # Create an Esprit object
39
+ esprit = Esprit(
40
+ driver_path="C:/path/to/chromedriver.exe")
41
+
42
+ # Attempt to log in
43
+ esprit.login(id, password)
44
+
45
+ # Get grades
46
+ grades = esprit.get_grades()
47
+
48
+ except Exception as e:
49
+ print(f"An error occurred: {e}. Retrying...")
50
+
51
+ if grades is not None:
52
+ for grade in grades:
53
+ print(grade)
54
+ else:
55
+ print("Failed to get grades.")
56
+
57
+ esprit.calculate_average(grades)
58
+
59
+ ```
60
+
61
+ get a list of all your absences;
39
62
 
40
63
  ```python
41
64
  from esprit import Esprit
@@ -64,4 +87,4 @@ else:
64
87
 
65
88
  ```
66
89
 
67
- More examples can be found in the [examples folder](examples)
90
+ More examples can be found in the [examples folder](examples)
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
 
4
3
 
@@ -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
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
 
4
3
 
@@ -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()
@@ -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
 
@@ -1,4 +1,3 @@
1
- import requests
2
1
  from bs4 import BeautifulSoup
3
2
  from datetime import datetime
4
3
  import re
@@ -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
@@ -0,0 +1,107 @@
1
+ Metadata-Version: 2.1
2
+ Name: esprit-py
3
+ Version: 0.3.4
4
+ Summary: A Python library for interacting with data from esprit-tn.com
5
+ Home-page: https://github.com/TheLime1/esprit.py
6
+ Author: Lime1 (Aymen Hmani)
7
+ Keywords: python,api
8
+ Classifier: Development Status :: 1 - Planning
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: Unix
12
+ Classifier: Operating System :: MacOS :: MacOS X
13
+ Classifier: Operating System :: Microsoft :: Windows
14
+ Description-Content-Type: text/markdown
15
+ License-File: LICENSE
16
+
17
+
18
+ # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
19
+
20
+ > [!NOTE]
21
+ > Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
22
+
23
+ ## Features
24
+
25
+ - Get your exact timetable pdf *not 300 pages pdf*
26
+ - Get your grades
27
+ - Get your absences
28
+ - Get your credits
29
+ - Calculate your total semester average
30
+
31
+ ## Installation
32
+
33
+ ```bash
34
+ pip install esprit-py
35
+ ```
36
+
37
+ download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
38
+
39
+ ## Examples
40
+
41
+ get your total avreage:
42
+
43
+ ```python
44
+ from esprit import Esprit
45
+
46
+ # Replace with your actual ID and password
47
+ id = 'ID'
48
+ password = 'PASSWORD'
49
+
50
+ grades = None
51
+
52
+ # Keep trying to get grades until it is successful cuz esprit use garabage servers
53
+ while grades is None:
54
+ try:
55
+ # Create an Esprit object
56
+ esprit = Esprit(
57
+ driver_path="C:/path/to/chromedriver.exe")
58
+
59
+ # Attempt to log in
60
+ esprit.login(id, password)
61
+
62
+ # Get grades
63
+ grades = esprit.get_grades()
64
+
65
+ except Exception as e:
66
+ print(f"An error occurred: {e}. Retrying...")
67
+
68
+ if grades is not None:
69
+ for grade in grades:
70
+ print(grade)
71
+ else:
72
+ print("Failed to get grades.")
73
+
74
+ esprit.calculate_average(grades)
75
+
76
+ ```
77
+
78
+ get a list of all your absences;
79
+
80
+ ```python
81
+ from esprit import Esprit
82
+
83
+ # Create an Esprit object
84
+ esprit = Esprit(
85
+ driver_path="C:/path/to/chromedriver.exe",)
86
+
87
+ # Replace with your actual ID and password
88
+ id = 'ID'
89
+ password = 'PASSWORD'
90
+
91
+ # Attempt to log in
92
+ if esprit.login(id, password):
93
+ print("Login successful.")
94
+ else:
95
+ print("Login failed.")
96
+
97
+ # Get absences
98
+ absences = esprit.get_absences()
99
+ if absences is not None:
100
+ for absence in absences:
101
+ print(absence)
102
+ else:
103
+ print("Failed to get absences.")
104
+
105
+ ```
106
+
107
+ More examples can be found in the [examples folder](examples)
@@ -8,6 +8,7 @@ esprit/credit.py
8
8
  esprit/esprit.py
9
9
  esprit/grade.py
10
10
  esprit/time_schedule.py
11
+ esprit/utils.py
11
12
  esprit_py.egg-info/PKG-INFO
12
13
  esprit_py.egg-info/SOURCES.txt
13
14
  esprit_py.egg-info/dependency_links.txt
@@ -11,7 +11,7 @@ with codecs.open(os.path.join(here, "README.md"), encoding="utf-8") as fh:
11
11
  with open(os.path.join(here, 'requirements.txt')) as f:
12
12
  requirements = f.read().splitlines()
13
13
 
14
- VERSION = '0.3.3'
14
+ VERSION = '0.3.4'
15
15
  DESCRIPTION = ' A Python library for interacting with data from esprit-tn.com'
16
16
  LONG_DESCRIPTION = 'esprit-py, provides a set of tools for interacting with data from the Esprit website. It includes functionalities for scraping grades, absences, time schedules, and credits. It also provides the ability to download files and get class week schedules.'
17
17
 
esprit-py-0.3.3/README.md DELETED
@@ -1,50 +0,0 @@
1
- # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
2
-
3
- > [!NOTE]
4
- > Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
5
-
6
- ## Features
7
-
8
- - Get your exact timetable pdf *not 300 pages pdf*
9
- - Get your grades
10
- - Get your absences
11
- - Get your credits
12
-
13
- ## Installation
14
-
15
- ```bash
16
- pip install esprit-py
17
- ```
18
-
19
- download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
20
-
21
- ## Example
22
-
23
- ```python
24
- from esprit import Esprit
25
-
26
- # Create an Esprit object
27
- esprit = Esprit(
28
- driver_path="C:/path/to/chromedriver.exe",)
29
-
30
- # Replace with your actual ID and password
31
- id = 'ID'
32
- password = 'PASSWORD'
33
-
34
- # Attempt to log in
35
- if esprit.login(id, password):
36
- print("Login successful.")
37
- else:
38
- print("Login failed.")
39
-
40
- # Get absences
41
- absences = esprit.get_absences()
42
- if absences is not None:
43
- for absence in absences:
44
- print(absence)
45
- else:
46
- print("Failed to get absences.")
47
-
48
- ```
49
-
50
- More examples can be found in the [examples folder](examples)
@@ -1,67 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: esprit-py
3
- Version: 0.3.3
4
- Summary: A Python library for interacting with data from esprit-tn.com
5
- Home-page: https://github.com/TheLime1/esprit.py
6
- Author: Lime1 (Aymen Hmani)
7
- Keywords: python,api
8
- Classifier: Development Status :: 1 - Planning
9
- Classifier: Intended Audience :: Developers
10
- Classifier: Programming Language :: Python :: 3
11
- Classifier: Operating System :: Unix
12
- Classifier: Operating System :: MacOS :: MacOS X
13
- Classifier: Operating System :: Microsoft :: Windows
14
- Description-Content-Type: text/markdown
15
- License-File: LICENSE
16
-
17
-
18
- # <img src="https://esprit.tn/favicon.ico" width="28px" /> esprit-py
19
-
20
- > [!NOTE]
21
- > Please note that this library is not an official API provided by Esprit and is intended for educational and personal use only.
22
-
23
- ## Features
24
-
25
- - Get your exact timetable pdf *not 300 pages pdf*
26
- - Get your grades
27
- - Get your absences
28
- - Get your credits
29
-
30
- ## Installation
31
-
32
- ```bash
33
- pip install esprit-py
34
- ```
35
-
36
- download `chromedriver` from [here](https://googlechromelabs.github.io/chrome-for-testing/#stable)
37
-
38
- ## Example
39
-
40
- ```python
41
- from esprit import Esprit
42
-
43
- # Create an Esprit object
44
- esprit = Esprit(
45
- driver_path="C:/path/to/chromedriver.exe",)
46
-
47
- # Replace with your actual ID and password
48
- id = 'ID'
49
- password = 'PASSWORD'
50
-
51
- # Attempt to log in
52
- if esprit.login(id, password):
53
- print("Login successful.")
54
- else:
55
- print("Login failed.")
56
-
57
- # Get absences
58
- absences = esprit.get_absences()
59
- if absences is not None:
60
- for absence in absences:
61
- print(absence)
62
- else:
63
- print("Failed to get absences.")
64
-
65
- ```
66
-
67
- More examples can be found in the [examples folder](examples)
File without changes
File without changes
File without changes