Documentation
¶
Index ¶
- Constants
- Variables
- func GetAllFilesWithExtension(inDir string, extension string) []string
- func GetCoursePrefixes(chromedpCtx context.Context) []string
- func GetMapKeys[M ~map[K]V, K comparable, V any](m M) []K
- func GetMapValues[M ~map[K]V, K comparable, V any](m M) []V
- func InitChromeDp() (chromedpCtx context.Context, cancelFnc context.CancelFunc)
- func RefreshAstraToken(chromedpCtx context.Context) map[string][]string
- func RefreshToken(chromedpCtx context.Context) map[string][]string
- func Regexpf(format string, vars ...interface{}) *regexp.Regexp
- func RetryHTTP(requestCreator func() *http.Request, client *http.Client, ...) (res *http.Response, err error)
- func TrimWhitespace(text string) string
- func VPrint(text string)
- func VPrintf(format string, vars ...any)
- func VPrintln(text string)
- func WriteJSON(filepath string, data interface{}) error
- type Logger
- type SplitWriter
Constants ¶
const Lverbose = 1 << 7
Verbose logging flag, only works with the utils.Logger verbose functions
const R_COURSE_CODE string = `[0-9vV]{4}`
Course code, i.e. 2252. The first digit of a course code is the course level, the second digit is the # of credit hours.
const R_DATE_MDY string = `[A-z]+\s+[0-9]+,\s+[0-9]{4}`
Date in <MONTH DAY, YEAR> format, i.e. January 5, 2022
const R_GRADE string = `[ABCFabcf][+-]?`
Grade, i.e. C-
const R_SECTION_CODE string = `[0-9A-z]+`
Section code, i.e. 101
const R_SUBJECT string = `[A-Z]{2,4}`
Subject, i.e. HIST
const R_SUBJ_COURSE string = `[A-Z]{2,4}\s*[0-9vV]{4}`
Subject + Course, uncaptured
const R_SUBJ_COURSE_CAP string = `([A-Z]{2,4})\s*([0-9vV]{4})`
Subject + Course, captured
const R_TERM_CODE string = `[0-9]{2}[sufSUF]`
Term/Semester code, i.e. 22s
const R_TIME_AM_PM string = `[0-9]+:[0-9]+\s*(?:am|pm)`
Time in 12-hour AM/PM format, i.e. 5:22pm
const R_WEEKDAY string = `(?:Mon|Tues|Wednes|Thurs|Fri|Satur|Sun)day`
Day of week, i.e. Monday
const R_YEARS string = `(?:freshm[ae]n|sophomores?|juniors?|seniors?)`
Year statuses
Variables ¶
var Headless = true
Functions ¶
func GetAllFilesWithExtension ¶
Recursively gets the filepath of every file with the given extension, using the given directory as the root.
func GetCoursePrefixes ¶
func GetMapKeys ¶
func GetMapKeys[M ~map[K]V, K comparable, V any](m M) []K
Gets all of the keys from a given map.
func GetMapValues ¶
func GetMapValues[M ~map[K]V, K comparable, V any](m M) []V
Gets all of the values from a given map.
func InitChromeDp ¶
func InitChromeDp() (chromedpCtx context.Context, cancelFnc context.CancelFunc)
Initializes Chrome DevTools Protocol
func RefreshAstraToken ¶
This function signs into Astra
func RefreshToken ¶
This function generates a fresh auth token and returns the new headers
func RetryHTTP ¶
func RetryHTTP(requestCreator func() *http.Request, client *http.Client, retryCallback func(res *http.Response, numRetries int)) (res *http.Response, err error)
Attempts to run the given HTTP request with the given HTTP client, wrapping the request with a retry callback
func TrimWhitespace ¶
Removes standard whitespace characters (space, tab, newline, carriage return) from a given string.
Types ¶
type Logger ¶
Extension of log.Logger that supports a verbose logging flag; verbose printing functions start with 'V'
type SplitWriter ¶
type SplitWriter struct {
// contains filtered or unexported fields
}
Custom io.Writer for routing writing to multiple sub-writers
func NewSplitWriter ¶
func NewSplitWriter(writers ...io.Writer) *SplitWriter
Constructor for utils.SplitWriter