diff --git a/CHANGELOG.md b/CHANGELOG.md index 0db6277..fb74f02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [0.3.1] - 2024-08-12 + +### Changed +- Extended method `ex_fetch_courses` now detects a 403 response +- The package-wide logger is now public + +### Added +- Logging was added to the extended api module + ## [0.3.0] - 2024-08-11 ### Added diff --git a/blackboard/__init__.py b/blackboard/__init__.py index de64416..6fc72fd 100644 --- a/blackboard/__init__.py +++ b/blackboard/__init__.py @@ -9,5 +9,5 @@ __all__ = ['BlackboardSession'] -_logger = logging.getLogger(__name__) -_logger.addHandler(logging.NullHandler()) +logger = logging.getLogger(__name__) +logger.addHandler(logging.NullHandler()) diff --git a/blackboard/api_extended.py b/blackboard/api_extended.py index 7a60132..8fcfa02 100644 --- a/blackboard/api_extended.py +++ b/blackboard/api_extended.py @@ -21,11 +21,15 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA. +import logging from typing import Any from .blackboard import BBCourse from .api import BlackboardSession from .filters import BBMembershipFilter +from .exceptions import BBForbiddenError + +logger = logging.getLogger(__name__) class BlackboardExtended(BlackboardSession): @@ -47,22 +51,15 @@ def ex_fetch_courses(self, *, for ms in memberships: if ms.availability: - private = False - - assert ms.courseId is not None - try: course = self.fetch_courses(course_id=ms.courseId) - except ValueError as e: # soon to change - private = str(e) == 'Private course' - # log please - raise e - - # mypy does not know result of calling API - assert isinstance(course, BBCourse) - course = course.model_copy(update={'created': ms.created}) - - if not private: + except BBForbiddenError: + logger.warning(f"Course {ms.courseId} is not available") + pass + else: + # mypy does not know result of calling API + assert isinstance(course, BBCourse) + course = course.model_copy(update={'created': ms.created}) courses.append(course) return courses