<commit_before>import yaml
import time

class Config():
    """
    Load the cyanite configuration.
    """

    def __init__(self, config_file):
        self.config_file = config_file
        self.verboseflag = False
        try:
            with open(config_file, 'r') as f:
                self.config = yaml.load(f)
        except IOError:
            self.config = dict()
        self.timewindow = 86400 * 3

    def cluster(self):
        casshosts = []
        if 'store' in self.config:
            if 'cluster' in self.config['store']:
                if isinstance(self.config['store']['cluster'], basestring):
                    casshosts.append(self.config['store']['cluster'])
                    return casshosts
                for host in self.config['store']['cluster']:
                    casshosts.append(host)
                return casshosts
        return ['localhost']

    def clusteruser(self):
        if 'store' in self.config:
            if 'username' in self.config['store']:
                return self.config['store']['username']
        return None

    def clusterpass(self):
        if 'store' in self.config:
            if 'password' in self.config['store']:
                return self.config['store']['password']
        return None

    def keyspace(self):
        if 'store' in self.config:
            if 'keyspace' in self.config['store']:
                return self.config['store']['keyspace']
        return 'metric'

    def httphost(self):
        return 'localhost'

    def httpport(self):
        if 'http' in self.config:
            if 'port' in self.config['http']:
                return self.config['http']['port']
        return '8080'

    def rollups(self):
        rollups = list()
        if 'carbon' in self.config:
            if 'rollups' in self.config['carbon']:
                for r in self.config['carbon']['rollups']:
                    if 'period' in r:
                        rollups.append((r['period'], r['rollup']))
                    else:
                        rollups.append(self._convert_shorthand_rollup(r[0]))
        return rollups

    def _convert_shorthand_rollup(shorthand_rollup, self):
        rollup, period = shorthand_rollup.split(':')
        return (self._to_seconds(period), self._to_seconds(rollup))

    def _to_seconds(value, self):
        quantity = value[-1:]
        val = int(value[:-1])

        if quantity == 's':
            return val
        elif quantity == 'm':
            return val*60
        elif quantity == 'h':
            return val*60*60
        elif quantity == 'd':
            return val*60*60*24
        elif quantity == 'w':
            return val*60*60*24*7
        elif quantity == 'y':
            return val*60*60*24*365

    def timefrom(self):
        now = int(time.time())
        return now - self.timewindow

    def settimefrom(self, timewindow):<commit_msg>not an array, just a string<commit_after>import yaml
import time

class Config():
    """
    Load the cyanite configuration.
    """

    def __init__(self, config_file):
        self.config_file = config_file
        self.verboseflag = False
        try:
            with open(config_file, 'r') as f:
                self.config = yaml.load(f)
        except IOError:
            self.config = dict()
        self.timewindow = 86400 * 3

    def cluster(self):
        casshosts = []
        if 'store' in self.config:
            if 'cluster' in self.config['store']:
                if isinstance(self.config['store']['cluster'], basestring):
                    casshosts.append(self.config['store']['cluster'])
                    return casshosts
                for host in self.config['store']['cluster']:
                    casshosts.append(host)
                return casshosts
        return ['localhost']

    def clusteruser(self):
        if 'store' in self.config:
            if 'username' in self.config['store']:
                return self.config['store']['username']
        return None

    def clusterpass(self):
        if 'store' in self.config:
            if 'password' in self.config['store']:
                return self.config['store']['password']
        return None

    def keyspace(self):
        if 'store' in self.config:
            if 'keyspace' in self.config['store']:
                return self.config['store']['keyspace']
        return 'metric'

    def httphost(self):
        return 'localhost'

    def httpport(self):
        if 'http' in self.config:
            if 'port' in self.config['http']:
                return self.config['http']['port']
        return '8080'

    def rollups(self):
        rollups = list()
        if 'carbon' in self.config:
            if 'rollups' in self.config['carbon']:
                for r in self.config['carbon']['rollups']:
                    if 'period' in r:
                        rollups.append((r['period'], r['rollup']))
                    else:
                        rollups.append(self._convert_shorthand_rollup(r))
        return rollups

    def _convert_shorthand_rollup(shorthand_rollup, self):
        rollup, period = shorthand_rollup.split(':')
        return (self._to_seconds(period), self._to_seconds(rollup))

    def _to_seconds(value, self):
        quantity = value[-1:]
        val = int(value[:-1])

        if quantity == 's':
            return val
        elif quantity == 'm':
            return val*60
        elif quantity == 'h':
            return val*60*60
        elif quantity == 'd':
            return val*60*60*24
        elif quantity == 'w':
            return val*60*60*24*7
        elif quantity == 'y':
            return val*60*60*24*365

    def timefrom(self):
        now = int(time.time())
        return now - self.timewindow

    def settimefrom(self, timewindow):
{'fraction_non_alphanumeric': 0.1223541559112029, 'fraction_numerical': 0.013939081053175014, 'mean_word_length': 1.7571157495256167, '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': '3791961', 'n_tokens_mistral': 1709, 'n_tokens_neox': 1580, 'n_words': 404}