Skip to content

Commit

Permalink
Update README and version
Browse files Browse the repository at this point in the history
  • Loading branch information
aditeyabaral committed Apr 19, 2024
1 parent 6f84dc4 commit 9803205
Show file tree
Hide file tree
Showing 13 changed files with 121 additions and 107 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Lint

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
lint:
Expand Down
36 changes: 18 additions & 18 deletions .github/workflows/python-package-pip.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
name: Python Package using Pip
name: Python Package using Pip

on: [push, pull_request]
on: [ push, pull_request ]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
max-parallel: 5
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: [ "3.9", "3.10", "3.11" ]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
pip install -r requirements.txt
- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
34 changes: 17 additions & 17 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ name: Upload Python Package

on:
release:
types: [published]
types: [ published ]

permissions:
contents: read
Expand All @@ -21,19 +21,19 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
# PESU Academy API
# pesuacademy-py

![PyPI](https://img.shields.io/pypi/v/pesuacademy?label=pypi%20package)
![GitHub Release](https://img.shields.io/github/v/release/HackerSpace-PESU/pesuacademy-py)
![GitHub Tag](https://img.shields.io/github/v/tag/HackerSpace-PESU/pesuacademy-py)
![PyPI - Status](https://img.shields.io/pypi/status/pesuacademy)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/pesuacademy)

![GitHub commit activity](https://img.shields.io/github/commit-activity/w/HackerSpace-PESU/pesuacademy-py)
![GitHub last commit](https://img.shields.io/github/last-commit/HackerSpace-PESU/pesuacademy-py)
![GitHub commits since latest release](https://img.shields.io/github/commits-since/HackerSpace-PESU/pesuacademy-py/latest)

![black.yml](https://github.com/HackerSpace-PESU/pesuacademy-py/actions/workflows/black.yml/badge.svg)
![python-package-pip.yml](https://github.com/HackerSpace-PESU/pesuacademy-py/actions/workflows/python-package-pip.yml/badge.svg)
![python-publish.yml](https://github.com/HackerSpace-PESU/pesuacademy-py/actions/workflows/python-publish.yml/badge.svg)

Python wrapper and APIs for the PESU Academy website.

The wrapper requires the user's credentials to authenticate and provide **read-only** access to all the pages and
information accessible on the PESU Academy website. Without the credentials, the wrapper will only be able to fetch
details from the `Know Your Class and Section` page.
The wrapper provides **read-only** access to all the pages and information accessible on the PESU Academy website.
Without authentication, the wrapper will only be able to fetch details from the `Know Your Class and Section` page.

> :warning: **Warning:** This is not an official API and is not endorsed by PES University. Use at your own risk.
Expand All @@ -30,6 +43,7 @@ python setup.py install
from pesuacademy import PESUAcademy

p = PESUAcademy("PRN_or_SRN", "password")
# p = PESUAcademy() # Without authentication: can only fetch details from the `Know Your Class and Section` page
profile = p.profile()
courses = p.courses(semester=2)
attendance = p.attendance()
Expand Down
2 changes: 1 addition & 1 deletion pesuacademy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = "0.0.1"
__version__ = "0.0.2"

from .pesuacademy import PESUAcademy
20 changes: 10 additions & 10 deletions pesuacademy/models/course.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

class Attendance:
def __init__(
self,
attended_classes: Optional[int] = None,
total_classes: Optional[int] = None,
percentage: Optional[float] = None,
self,
attended_classes: Optional[int] = None,
total_classes: Optional[int] = None,
percentage: Optional[float] = None,
):
self.attended_classes = attended_classes
self.total_classes = total_classes
Expand All @@ -18,12 +18,12 @@ def __str__(self):

class Course:
def __init__(
self,
code: str,
title: str,
_type: Optional[str] = None,
status: Optional[str] = None,
attendance: Optional[Attendance] = None,
self,
code: str,
title: str,
_type: Optional[str] = None,
status: Optional[str] = None,
attendance: Optional[Attendance] = None,
):
self.code = code
self.title = title
Expand Down
72 changes: 36 additions & 36 deletions pesuacademy/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

class ClassAndSectionInfo:
def __init__(
self,
prn: str,
srn: str,
name: str,
semester: str,
section: str,
department: str,
branch: str,
institute: str,
cycle: Optional[str] = None,
self,
prn: str,
srn: str,
name: str,
semester: str,
section: str,
department: str,
branch: str,
institute: str,
cycle: Optional[str] = None,
):
self.prn = prn
self.srn = srn
Expand All @@ -31,18 +31,18 @@ def __str__(self):

class PersonalDetails:
def __init__(
self,
name: str,
prn: str,
srn: str,
branch: str,
semester: str,
section: str,
program: Optional[str] = None,
email: Optional[str] = None,
mobile: Optional[str] = None,
aadhar: Optional[str] = None,
name_as_in_aadhar: Optional[str] = None,
self,
name: str,
prn: str,
srn: str,
branch: str,
semester: str,
section: str,
program: Optional[str] = None,
email: Optional[str] = None,
mobile: Optional[str] = None,
aadhar: Optional[str] = None,
name_as_in_aadhar: Optional[str] = None,
):
self.name = name
self.prn = prn
Expand Down Expand Up @@ -83,14 +83,14 @@ def __str__(self):

class ParentInformation:
def __init__(
self,
name: str,
mobile: str,
email: str,
occupation: str,
qualification: str,
designation: str,
employer: str,
self,
name: str,
mobile: str,
email: str,
occupation: str,
qualification: str,
designation: str,
employer: str,
):
self.name = name
self.mobile = mobile
Expand Down Expand Up @@ -125,12 +125,12 @@ def __str__(self):

class Profile:
def __init__(
self,
personal_details: PersonalDetails,
other_information: OtherInformation,
qualifying_examination: QualifyingExamination,
parent_details: ParentDetails,
address_details: AddressDetails,
self,
personal_details: PersonalDetails,
other_information: OtherInformation,
qualifying_examination: QualifyingExamination,
parent_details: ParentDetails,
address_details: AddressDetails,
):
self.personal_details = personal_details
self.other_information = other_information
Expand Down
8 changes: 4 additions & 4 deletions pesuacademy/pages/attendance.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class AttendancePageHandler:
@staticmethod
def get_attendance_in_semester(
session: requests_html.HTMLSession, semester_value: Optional[int] = None
session: requests_html.HTMLSession, semester_value: Optional[int] = None
):
try:
url = "https://www.pesuacademy.com/Academy/s/studentProfilePESUAdmin"
Expand All @@ -34,8 +34,8 @@ def get_attendance_in_semester(
for row in table_body.find_all("tr"):
columns = row.find_all("td")
if (
len(columns) == 1
and columns[0].text.strip() == "Data Not\n\t\t\t\t\tAvailable"
len(columns) == 1
and columns[0].text.strip() == "Data Not\n\t\t\t\t\tAvailable"
):
break
course_code = columns[0].text.strip()
Expand All @@ -59,7 +59,7 @@ def get_attendance_in_semester(

@staticmethod
def get_page(
session: requests_html.HTMLSession, semester_ids: dict
session: requests_html.HTMLSession, semester_ids: dict
) -> dict[int, list[Course]]:
attendance = dict()
for semester_number in semester_ids:
Expand Down
8 changes: 4 additions & 4 deletions pesuacademy/pages/courses.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class CoursesPageHandler:
@staticmethod
def get_courses_in_semester(
session: requests_html.HTMLSession, semester_id: Optional[int] = None
session: requests_html.HTMLSession, semester_id: Optional[int] = None
):
try:
url = "https://www.pesuacademy.com/Academy/s/studentProfilePESUAdmin"
Expand All @@ -34,8 +34,8 @@ def get_courses_in_semester(
for row in table_body.find_all("tr"):
columns = row.find_all("td")
if (
len(columns) == 1
and columns[0].text.strip() == "No\n\t\t\t\t\t\tsubjects found"
len(columns) == 1
and columns[0].text.strip() == "No\n\t\t\t\t\t\tsubjects found"
):
break
course_code = columns[0].text.strip()
Expand All @@ -48,7 +48,7 @@ def get_courses_in_semester(

@staticmethod
def get_page(
session: requests_html.HTMLSession, semester_ids: dict
session: requests_html.HTMLSession, semester_ids: dict
) -> dict[int, list[Course]]:
courses = dict()
for semester_number in semester_ids:
Expand Down
2 changes: 1 addition & 1 deletion pesuacademy/pesuacademy.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def authenticated(self):
return self._authenticated

def generate_csrf_token(
self, username: Optional[str] = None, password: Optional[str] = None
self, username: Optional[str] = None, password: Optional[str] = None
) -> str:
"""
Generate a CSRF token. If username and password are provided, authenticate and get the CSRF token.
Expand Down
4 changes: 2 additions & 2 deletions pesuacademy/util/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ def set_semester_id_to_number_mapping(self, csrf_token: str):
self._semester_ids = semesters

def get_semester_ids_from_semester_number(
self, semester: Optional[int] = None
self, semester: Optional[int] = None
) -> dict:
"""
Get the semester ids from the semester number. If semester is not provided, all semester ids are returned.
:param semester: The semester number.
:return: The semester ids mapping.
"""
assert (
semester is None or 1 <= semester <= 8
semester is None or 1 <= semester <= 8
), "Semester number should be between 1 and 8."
return (
self._semester_ids
Expand Down
Loading

0 comments on commit 9803205

Please sign in to comment.