<commit_before>#!/usr/bin/env python3

import configparser

import requests
import os
from datetime import datetime, timedelta

from flask import Flask, Response, abort

class ServiceUnavailableException(Exception):
    """Used for the campus service not functioning correct."""
    pass

class CampusICSFetcher:
    """Fetches the ICS file from Campus."""


    def __init__(self, config_path="default.ini"):
        """Reads in config from config_path (default: default.ini)
        and sets configuration accordingly."""

        # Change working dir to script dir
        abspath = os.path.abspath(__file__)
        dir_name = os.path.dirname(abspath)
        os.chdir(dir_name)

        config_file_locations = [ config_path, "/etc/campus_ics_feed.ini" ]

        if os.environ.get("CAMPUS_CONFIG_FILE"):
            config_file_locations.append(os.environ.get("CAMPUS_CONFIG_FILE"))

        for cfg_file in config_file_locations:
            if os.path.isfile(cfg_file):
                config = configparser.ConfigParser()
                config.read(cfg_file)
                self.campus_user           = config["Campus"]["Username"]
                self.campus_password       = config["Campus"]["Password"]
                break
        else:
            print("Please provide a configuration file named "
                    + " or ".join(map(lambda x: "'" + str(x) + "'", config_file_locations)) + ".")
            exit()

    def fetch(self):
        """Fetches the ICS file."""<commit_msg>Changing spelling of config file.<commit_after>#!/usr/bin/env python3

import configparser

import requests
import os
from datetime import datetime, timedelta

from flask import Flask, Response, abort

class ServiceUnavailableException(Exception):
    """Used for the campus service not functioning correct."""
    pass

class CampusICSFetcher:
    """Fetches the ICS file from Campus."""


    def __init__(self, config_path="default.ini"):
        """Reads in config from config_path (default: default.ini)
        and sets configuration accordingly."""

        # Change working dir to script dir
        abspath = os.path.abspath(__file__)
        dir_name = os.path.dirname(abspath)
        os.chdir(dir_name)

        config_file_locations = [ config_path, "/etc/campus-ics-feed.ini" ]

        if os.environ.get("CAMPUS_CONFIG_FILE"):
            config_file_locations.append(os.environ.get("CAMPUS_CONFIG_FILE"))

        for cfg_file in config_file_locations:
            if os.path.isfile(cfg_file):
                config = configparser.ConfigParser()
                config.read(cfg_file)
                self.campus_user           = config["Campus"]["Username"]
                self.campus_password       = config["Campus"]["Password"]
                break
        else:
            print("Please provide a configuration file named "
                    + " or ".join(map(lambda x: "'" + str(x) + "'", config_file_locations)) + ".")
            exit()

    def fetch(self):
        """Fetches the ICS file."""
{'fraction_non_alphanumeric': 0.10740251156642432, 'fraction_numerical': 0.0006609385327164573, 'mean_word_length': 2.4633867276887873, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1809920', 'n_tokens_mistral': 865, 'n_tokens_neox': 837, 'n_words': 207}