<commit_before># -*- coding: utf-8 -*-

import ConfigParser
import sys
import subprocess
import os
from os.path import join as joinPath


class Station:
    def __init__(self, name, url, playlist):
        self.name = name
        self.url = url
        self.playlist = playlist
    def __str__(self):
        return self.name


class Status:
    def __init__(self, station, number, pid, tag=""):
        self.station = station
        self.pid = str(pid)
        self.number = str(number)
        self.tag = tag

    def writeToFile(self, dir):
        with open(joinPath(dir, "station"), "w") as ff:
            ff.write(self.station.name)
        with open(joinPath(dir, "pid"), "a") as ff:
            ff.write(self.pid+"\n")
        with open(joinPath(dir, "url"), "w") as ff:
            ff.write(self.station.url)
        with open(joinPath(dir, "number"), "w") as ff:
            ff.write(self.number)

    def __str__(self):
        out = ""
        out += self.number
        out += "\n" + self.station
        out += "\n" + self.url
        if tag:
            out += "\n" + self.tag
        return out


def getStatusFromFiles(dir):
    try:
        with open(joinPath(dir, "station"), "r") as ff:
            name = ff.readline()
        with open(joinPath(dir, "number"), "r") as ff:
            number = int(ff.readline())
        with open(joinPath(dir, "url"), "r") as ff:
            url = ff.readline()
        with open(joinPath(dir, "pid"), "r") as ff:
            pid = int(ff.readline())
        with open(jainPath(dir, "tag"), "r") as ff:
            tag = ff.readline()
    except IOError as e:
        print e
        return None

    station = Station(name, url, False)
    return Status(station, number, pid)

        
class Config:
    def __init__(self, configFile):
        config = ConfigParser.ConfigParser(defaults = {"playlist" : "yes"})
        config.read(configFile)
        self.stations = ["dummy"]
        try:            
            stationNames = config.get("Global", "stations")
            self.dirName = config.get("Global", "dir").rstrip("/")+"/"
            self.player = config.get("Global", "player")
            for stationName in stationNames.split():
                if not config.has_section(stationName):
                    print "no section", stationName
                    continue
                displayName = config.get(stationName, "name")
                url = config.get(stationName, "url")
                playlist = config.getboolean(stationName, "playlist")
                station = Station(displayName, url, playlist)
                self.stations.append(station)
        except Exception as e:<commit_msg>Correct typo in function name.<commit_after># -*- coding: utf-8 -*-

import ConfigParser
import sys
import subprocess
import os
from os.path import join as joinPath


class Station:
    def __init__(self, name, url, playlist):
        self.name = name
        self.url = url
        self.playlist = playlist
    def __str__(self):
        return self.name


class Status:
    def __init__(self, station, number, pid, tag=""):
        self.station = station
        self.pid = str(pid)
        self.number = str(number)
        self.tag = tag

    def writeToFile(self, dir):
        with open(joinPath(dir, "station"), "w") as ff:
            ff.write(self.station.name)
        with open(joinPath(dir, "pid"), "a") as ff:
            ff.write(self.pid+"\n")
        with open(joinPath(dir, "url"), "w") as ff:
            ff.write(self.station.url)
        with open(joinPath(dir, "number"), "w") as ff:
            ff.write(self.number)

    def __str__(self):
        out = ""
        out += self.number
        out += "\n" + self.station
        out += "\n" + self.url
        if tag:
            out += "\n" + self.tag
        return out


def getStatusFromFiles(dir):
    try:
        with open(joinPath(dir, "station"), "r") as ff:
            name = ff.readline()
        with open(joinPath(dir, "number"), "r") as ff:
            number = int(ff.readline())
        with open(joinPath(dir, "url"), "r") as ff:
            url = ff.readline()
        with open(joinPath(dir, "pid"), "r") as ff:
            pid = int(ff.readline())
        with open(joinPath(dir, "tag"), "r") as ff:
            tag = ff.readline()
    except IOError as e:
        print e
        return None

    station = Station(name, url, False)
    return Status(station, number, pid)

        
class Config:
    def __init__(self, configFile):
        config = ConfigParser.ConfigParser(defaults = {"playlist" : "yes"})
        config.read(configFile)
        self.stations = ["dummy"]
        try:            
            stationNames = config.get("Global", "stations")
            self.dirName = config.get("Global", "dir").rstrip("/")+"/"
            self.player = config.get("Global", "player")
            for stationName in stationNames.split():
                if not config.has_section(stationName):
                    print "no section", stationName
                    continue
                displayName = config.get(stationName, "name")
                url = config.get(stationName, "url")
                playlist = config.getboolean(stationName, "playlist")
                station = Station(displayName, url, playlist)
                self.stations.append(station)
        except Exception as e:
{'fraction_non_alphanumeric': 0.1323775833178179, 'fraction_numerical': 0.0003723701359150996, 'mean_word_length': 1.9259259259259258, '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': '2295194', 'n_tokens_mistral': 1620, 'n_tokens_neox': 1554, 'n_words': 423}