Course Parser

Management Commands

Course Parser Setup Command

This module provides a Django management command to setup course parsing by creating semester-specific department catalog links from a base file.

The command reads a base JSON file containing department links and modifies them to include the current semester identifier in the URLs.

Example

To run this command:

$ python manage.py course_parser_setup
Configuration:
  • SEMESTER: Global variable defining the current semester (e.g., "2526F")

  • BASE_DIR: Directory containing course catalog data

  • BASE_JSON_PATH: Path to the base department links file

  • TARGET_JSON_PATH: Path where the modified file will be saved

class amherst_coursework_algo.management.commands.course_parser_setup.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Django management command to prepare department catalog links for course parsing.

This command reads department links from a base JSON file and modifies them to include the current semester identifier in the URLs. The modified links are then saved to a new JSON file for use by the course parser.

help

Brief command description shown in manage.py help

Type:

str

File Structure:
  • Input: department_catalogue_links_base.json

    Contains base URLs for department course pages

  • Output: department_catalogue_links.json

    Contains URLs modified to include current semester

handle(*args, **options)[source]

Execute the command to create semester-specific department catalog links.

Parameters:
  • *args -- Variable length argument list

  • **options -- Arbitrary keyword arguments

Raises:
  • FileNotFoundError -- If the base JSON file is not found

  • Exception -- For other errors during execution

Example JSON structure:

[
    {
        "name": "American Studies",
        "url": "https://www.amherst.edu/academiclife/departments/american_studies/courses"
    }
]