Skip to content

Commit

Permalink
Remove unused import statements
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLime1 committed Feb 16, 2024
1 parent c8d238c commit bb1333e
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 4 deletions.
1 change: 0 additions & 1 deletion esprit/absence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from bs4 import BeautifulSoup


Expand Down
1 change: 0 additions & 1 deletion esprit/credit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from bs4 import BeautifulSoup


Expand Down
9 changes: 9 additions & 0 deletions esprit/esprit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from .absence import Absence
from .time_schedule import TimeSchedule
from .credit import Credit
from .utils import Utils
# from .exceptions import EspritException #TODO


class Esprit:
Expand All @@ -14,6 +16,7 @@ def __init__(self, driver_path=None, driver=None, debug=False, headless=True):
self.absence_scrape = Absence(self.session)
self.time_schedule_scrape = TimeSchedule(self.session)
self.credit = Credit(self.session)
self.utils = Utils(self.session)

def login(self, username, password):
cookies = self.auth.login(username, password)
Expand Down Expand Up @@ -43,3 +46,9 @@ def get_class_week_schedule(self, file_path, class_name, result_path):

def get_credits(self):
return self.credit.get_credits()

def get_student_name(self):
return self.utils.get_student_name()

def get_student_class(self):
return self.utils.get_student_class()
1 change: 0 additions & 1 deletion esprit/grade.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from bs4 import BeautifulSoup
import pandas as pd
import numpy as np
Expand Down
1 change: 0 additions & 1 deletion esprit/time_schedule.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import requests
from bs4 import BeautifulSoup
from datetime import datetime
import re
Expand Down
58 changes: 58 additions & 0 deletions esprit/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
from bs4 import BeautifulSoup


class Utils:
"""
A utility class for interacting with the ESPRIT website.
"""

def __init__(self, session):
self.url = "https://esprit-tn.com/ESPOnline/Etudiants/Accueil.aspx"
self.session = session

def get_student_name(self):
"""
Get the name of the student from the ESPRIT website.
Returns:
The name of the student, or None if the name could not be found.
"""
response = self.session.get(self.url)
soup = BeautifulSoup(response.text, 'html.parser')

# Check if the <p> tag with the class "lead" and the text "Vous pouvez consulter dans cet espace :" exists
p_tag = soup.find('p', class_='lead',
text='Vous pouvez consulter dans cet espace :')
if p_tag is None:
print("The page does not contain the expected text.")
return None

span = soup.find('span', {'id': 'Label2', 'class': 'h4 text-info'})
if span is not None:
return span.text.strip()
else:
return None

def get_student_class(self):
"""
Get the class of the student from the ESPRIT website.
Returns:
The class of the student, or None if the class could not be found.
"""
response = self.session.get(self.url)
soup = BeautifulSoup(response.text, 'html.parser')

# Check if the <p> tag with the class "lead" and the text "Vous pouvez consulter dans cet espace :" exists
p_tag = soup.find('p', class_='lead',
text='Vous pouvez consulter dans cet espace :')
if p_tag is None:
print("The page does not contain the expected text.")
return None

span = soup.find(
'span', {'id': 'Label3', 'style': 'color:#CC0000;font-weight:bold;'})
if span is not None:
return span.text.strip()
else:
return None

0 comments on commit bb1333e

Please sign in to comment.