Skip to main content

Useful functions & utilities for Stuyvesant High School.

Project description

StuyUtils

Useful functions & utilities for Stuyvesant High School.

To download this module, run pip install stuy-utils in the terminal.

To test the module or see example code, navigate to the tests directory, then running the files there.

schedule.convert_to_isoformat(day)

Convert a date object to an ISO-formatted date string.

Convert a date or datetime object from the datetime library to a string formatted using the ISO 8601 format, while also checking if 'date' is a valid date and if it exists in the data.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • str: A date using the ISO 8601 format (yyyy-mm-dd).

schedule.get_day_info(day)

Returns information about a given day.

Returns the cycle, period, testing subjects, and any events of a given day. If a category does not apply, an empty string will be returned.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • Info: A namedtule with fields 'cycle', 'period', 'testing', and 'event'.

schedule.get_next_school_day(day, always_same)

Returns when the next school day is.

Returns a date object of the next school day from the given day. The given datetime will be returned as a date if school is still in session.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.
  • always_same (bool, optional): Whether or not to always return the given day if the given day is a school day. Defaults to False.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • Optional[datetime.date]: A date object with the year, month, and day of the next school day.

schedule.get_bell_schedule(day)

Returns the bell periods of the next school day.

Returns a dictionary of bell periods of the next school day. If the given day is a school day, then the bell schedule of that day will be returned, even if it is afterschool.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • Dict[str, Time]: A dictionary of keys of strings of the category name (see data/bell_schedule.csv) and values of Time namedtuple objects with fields 'start' and 'end', which returns a datetime object.

schedule.get_current_class(day)

Returns information of the current class.

Returns a tuple of information of the current class, where the first element is a string of the category, such as the class period, and a Time namedtuple object, which includes when said period starts and ends.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • Optional[Tuple[str, Time]]: A tuple of a string of the category name (see data/bell_schedule.csv), and a Time namedtuple object with fields 'start' and 'end', which returns a datetime object.

schedule.get_next_class(day)

Returns information of the next class.

Returns a tuple of information of the next class, where the first element is a string of the category, such as the class period, and a Time namedtuple object, which includes when said period starts and ends.

Args

  • day (Union[datetime.date, datetime.datetime]): A date or datetime object from the datetime library.

Raises

  • errors.InvalidDate: Thrown if the input is not a date or a datetime object.
  • errors.DayNotInData: Thrown if the inputted day is not in term_days.csv.

Returns

  • Optional[Tuple[str, Time]]: A tuple of a string of the category name (see data/bell_schedule.csv), and a Time namedtuple object with fields 'start' and 'end', which returns a datetime object.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stuy_utils-0.0.3.tar.gz (6.3 kB view details)

Uploaded Source

File details

Details for the file stuy_utils-0.0.3.tar.gz.

File metadata

  • Download URL: stuy_utils-0.0.3.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.2 CPython/3.9.1

File hashes

Hashes for stuy_utils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 32fb89c0a1f641bd00c7a6cc9ebf43087b5eaf7e8609dfe45811d523681cabad
MD5 7265a3bd50b861cfc05b351ca7de7d89
BLAKE2b-256 5206fab78e481b49b49e6e46c2f198510dbda0abbead91233333c3d303de5b94

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page