Utilities¶
General utilities.
codePost Utilities¶
Utilities involving the codePost SDK.
- @codepost_powertools.utils.codepost_utils.with_course¶
Decorates a function to fetch a course before calling.
This decorator will fetch a
Courseif necessary to call the decorated function.func(course: CourseArg, *args, **kwargs) -> RT # becomes func(course: Course | None, *args, **kwargs) -> RT
If the retrieval is unsuccessful,
coursewill be passed asNone, which the function should handle itself.New in version 0.1.0.
- @codepost_powertools.utils.codepost_utils.with_course_and_assignment¶
Decorates a function to fetch a course and assignment before calling.
This decorator will fetch a
CourseandAssignmentif necessary to call the decorated function.func( course: CourseArg, assignment: AssignmentArg, *args, **kwargs ) -> RT # becomes func( course: Course | None, assignment: Assignment | None, *args, **kwargs ) -> RT
If any retrievals are unsuccessful,
courseandassignmentwill both be passed asNone, which the function should handle itself.New in version 0.1.0.
- codepost_powertools.utils.codepost_utils.get_course(name, period, *, log=False)¶
Gets a codePost course.
If there are multiple courses with the same name and period, the first one found is returned.
- Parameters:
- Returns:
The course.
- Return type:
- Raises:
ValueError – If no course is found.
New in version 0.1.0.
- codepost_powertools.utils.codepost_utils.course_str(course, *, delim=' ')¶
Returns a str representation of a course.
- Parameters:
- Returns:
A string representation of the course.
- Return type:
New in version 0.1.0.
- codepost_powertools.utils.codepost_utils.get_course_roster(course, *, log=False)¶
Gets the roster for the given course.
- Parameters:
- Returns:
The roster.
- Return type:
New in version 0.1.0.
- codepost_powertools.utils.codepost_utils.get_assignment(course, assignment_name, *, log=False)¶
Gets a codePost assignment from a course.
If there are multiple assignments with the same name, the first one found is returned.
- Parameters:
- Returns:
The assignment.
- Return type:
- Raises:
ValueError – If the assignment is not found.
New in version 0.1.0.