<commit_before>"""
Copyright (c) 2016 <NAME>, <NAME>

Under MIT License - https://github.com/Step7750/ScheduleStorm/blob/master/LICENSE.md

This file is a resource for Schedule Storm - https://github.com/Step7750/ScheduleStorm
"""

import uni
from rmp import RateMyProfessors
import json
import inspect
import time
import logging
import sys
import falcon
from wsgiref import simple_server

# Store the threads for each uni
uniThreads = {}

# Logging
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
log = logging.getLogger("main")
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("wsgiref").setLevel(logging.WARNING)

def loadSettings():
    with open("settings.json") as settingFile:
        return json.load(settingFile)

settings = loadSettings()

class v1Unis():
    """
        Retrieves list of Unis
    """
    def on_get(self, req, resp):
        responsedict = {}

        for uni in list(uniThreads.keys()):
            responsedict[uni] = {"terms": uniThreads[uni].getTerms(),
                                 "locations": uniThreads[uni].getLocations(),
                                 "name": settings["Universities"][uni]["fullname"],
                                 "rmp": settings["Universities"][uni]["rmpid"]}

        resp.body = json.dumps(responsedict)

class v1GetAllUniTermSubjects():
    """
        Retrieves all subjects and classes for a given Uni
    """
    def on_get(self, req, resp, uni, term):
        # The term must be a string since the threads represent them as such
        if uni in uniThreads and term in uniThreads[uni].getTerms():
            resp.body = json.dumps(uniThreads[uni].getSubjectListAll(term), sort_keys=True)
        else:
            raise falcon.HTTPBadRequest('Resource Not Found',
                                        'The specified university or term was not found')

if __name__ == '__main__':

    # Instantiate the unis

    # Get the modules of uni
    unimemebers = inspect.getmembers(uni)
    rmpids = []

    log.info("Instantiating University Threads")

    # Foreach university in settings
    for university in settings["Universities"]:

        # Get the settings
        unisettings = settings["Universities"][university]


        # Only instantiate if they have it enabled in settings
        if "enabled" in unisettings and unisettings["enabled"]:
<commit_msg>Adds uniID to class settings<commit_after>"""
Copyright (c) 2016 <NAME>, <NAME>

Under MIT License - https://github.com/Step7750/ScheduleStorm/blob/master/LICENSE.md

This file is a resource for Schedule Storm - https://github.com/Step7750/ScheduleStorm
"""

import uni
from rmp import RateMyProfessors
import json
import inspect
import time
import logging
import sys
import falcon
from wsgiref import simple_server

# Store the threads for each uni
uniThreads = {}

# Logging
logging.basicConfig(stream=sys.stdout, level=logging.INFO)

log = logging.getLogger("main")
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("wsgiref").setLevel(logging.WARNING)

def loadSettings():
    with open("settings.json") as settingFile:
        return json.load(settingFile)

settings = loadSettings()

class v1Unis():
    """
        Retrieves list of Unis
    """
    def on_get(self, req, resp):
        responsedict = {}

        for uni in list(uniThreads.keys()):
            responsedict[uni] = {"terms": uniThreads[uni].getTerms(),
                                 "locations": uniThreads[uni].getLocations(),
                                 "name": settings["Universities"][uni]["fullname"],
                                 "rmp": settings["Universities"][uni]["rmpid"]}

        resp.body = json.dumps(responsedict)

class v1GetAllUniTermSubjects():
    """
        Retrieves all subjects and classes for a given Uni
    """
    def on_get(self, req, resp, uni, term):
        # The term must be a string since the threads represent them as such
        if uni in uniThreads and term in uniThreads[uni].getTerms():
            resp.body = json.dumps(uniThreads[uni].getSubjectListAll(term), sort_keys=True)
        else:
            raise falcon.HTTPBadRequest('Resource Not Found',
                                        'The specified university or term was not found')

if __name__ == '__main__':

    # Instantiate the unis

    # Get the modules of uni
    unimemebers = inspect.getmembers(uni)
    rmpids = []

    log.info("Instantiating University Threads")

    # Foreach university in settings
    for university in settings["Universities"]:

        # Get the settings
        unisettings = settings["Universities"][university]

        # Set the key
        unisettings["uniID"] = university

        # Only instantiate if they have it enabled in settings
        if "enabled" in unisettings and unisettings["enabled"]:

{'fraction_non_alphanumeric': 0.10430463576158941, 'fraction_numerical': 0.005794701986754967, 'mean_word_length': 2.850996015936255, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1900205', 'n_tokens_mistral': 1425, 'n_tokens_neox': 1346, 'n_words': 389}