<commit_before># coding: utf-8
from __future__ import absolute_import
import os
import yaml
from .exceptions import EnvironmentNotFound, FileNotFound
from .package import Package


class Config(object):

    def __init__(self, pyfile=None, environment='development'):
        if pyfile:
            self.pyfile = pyfile
        else:
            self.pyfile = os.path.join(os.getcwd(), 'Pyfile')

        self._check_file(self.pyfile)

        self.data = yaml.load(open(self.pyfile).read())
        self.environment = environment

    @property
    def packages(self):
        if self.environment not in self.data:
            raise EnvironmentNotFound(
                'not environment({}) in config file Pyfile'.format(
                    self.environment))

        return [
            Package(name, config)
            for name, config in self.data[self.environment].iteritems()
        ]

    def _check_file(self, filepath):
        if not os.path.exists(filepath):
            raise FileNotFound('config file({}) not found.'.format(filepath))
<commit_msg>Fix iteritems isn't a method name in Py3<commit_after># coding: utf-8
from __future__ import absolute_import
import os
import yaml
from .exceptions import EnvironmentNotFound, FileNotFound
from .package import Package


class Config(object):

    def __init__(self, pyfile=None, environment='development'):
        if pyfile:
            self.pyfile = pyfile
        else:
            self.pyfile = os.path.join(os.getcwd(), 'Pyfile')

        self._check_file(self.pyfile)

        self.data = yaml.load(open(self.pyfile).read())
        self.environment = environment

    @property
    def packages(self):
        if self.environment not in self.data:
            raise EnvironmentNotFound(
                'not environment({}) in config file Pyfile'.format(
                    self.environment))

        return [
            Package(name, config)
            for name, config in self.data[self.environment].items()
        ]

    def _check_file(self, filepath):
        if not os.path.exists(filepath):
            raise FileNotFound('config file({}) not found.'.format(filepath))

{'fraction_non_alphanumeric': 0.09986065954482118, 'fraction_numerical': 0.0013934045517882026, 'mean_word_length': 2.419047619047619, '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': '5785978', 'n_tokens_mistral': 595, 'n_tokens_neox': 569, 'n_words': 157}