<commit_before>"""Module that contains the file tailer configuration class.

.. moduleauthor:: <NAME> <<EMAIL>>

"""

import json
import os
import sys
import tempfile

import six
import six
import argparser

class O(object):
    """
    test object
    """


class Configurable(argparser.Namespace):
    """
    a configurable class
    """
    config_file = None
    config_url = None

    @classmethod
    def configure(cls, obj, **kwargs):
        cls.override(obj, **vars(cls))
        config_file = kwargs.pop('config_file', cls.config_file)
        if config_file:
            cls.override(obj, **cls.config_from_file(config_file))
        config_url = kwargs.pop('config_url', cls.config_url)
        if config_url:
            cls.override(obj, **cls.config_from_url(config_url))
        cls.override(obj, **kwargs)
        return obj

    @classmethod
    def config_from_file(cls, config_file_name):
        file_name, ext = os.path.splitext(os.path.abspath(config_file_name))
        configure_from_xxx = getattr(cls, 'config_from_' + ext[1:], cls.config_from_cfg)
        return configure_from_xxx(config_file_name)

    @classmethod
    def config_from_json(cls, config_file_name):
        return json.load(open(config_file_name, 'rb'))

    @classmethod
    def config_from_py(cls, pathname):
        if not os.path.isfile(pathname):
            raise IOError('File {0} not found.'.format(pathname))

        if sys.version_info[0] == 3 and sys.version_info[1] > 2:  # Python >= 3.3
            import importlib.machinery
            loader = importlib.machinery.SourceFileLoader('', pathname)
            mod = loader.load_module('')
        else:  # 2.6 >= Python <= 3.2
            import imp
            mod = imp.load_source('', pathname)
        return vars(mod)

    @classmethod
    def config_from_cfg(cls, config_file_name):
        config = six.configparser.ConfigParser()
        config.read(config_file_name)
        return config._sections

    @classmethod
    def config_from_url(cls, url):
        return requests.get(url).json()

    @classmethod<commit_msg>fixed bad reference to six.moves<commit_after>"""Module that contains the file tailer configuration class.

.. moduleauthor:: <NAME> <<EMAIL>>

"""

import json
import os
import sys

import argparse
import six
import requests






class Configurable(argparse.Namespace):
    """
    a configurable class
    """
    config_file = None
    config_url = None

    @classmethod
    def configure(cls, obj, **kwargs):
        cls.override(obj, **vars(cls))
        config_file = kwargs.pop('config_file', cls.config_file)
        if config_file:
            cls.override(obj, **cls.config_from_file(config_file))
        config_url = kwargs.pop('config_url', cls.config_url)
        if config_url:
            cls.override(obj, **cls.config_from_url(config_url))
        cls.override(obj, **kwargs)
        return obj

    @classmethod
    def config_from_file(cls, config_file_name):
        file_name, ext = os.path.splitext(os.path.abspath(config_file_name))
        configure_from_xxx = getattr(cls, 'config_from_' + ext[1:], cls.config_from_cfg)
        return configure_from_xxx(config_file_name)

    @classmethod
    def config_from_json(cls, config_file_name):
        return json.load(open(config_file_name, 'rb'))

    @classmethod
    def config_from_py(cls, pathname):
        if not os.path.isfile(pathname):
            raise IOError('File {0} not found.'.format(pathname))

        if sys.version_info[0] == 3 and sys.version_info[1] > 2:  # Python >= 3.3
            import importlib.machinery
            loader = importlib.machinery.SourceFileLoader('', pathname)
            mod = loader.load_module('')
        else:  # 2.6 >= Python <= 3.2
            import imp
            mod = imp.load_source('', pathname)
        return vars(mod)

    @classmethod
    def config_from_cfg(cls, config_file_name):
        config = six.moves.configparser.ConfigParser()
        config.read(config_file_name)
        return config._sections

    @classmethod
    def config_from_url(cls, url):
        return requests.get(url).json()

    @classmethod
{'fraction_non_alphanumeric': 0.11070911722141824, 'fraction_numerical': 0.005788712011577424, 'mean_word_length': 2.804587155963303, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '5294432', 'n_tokens_mistral': 1310, 'n_tokens_neox': 1284, 'n_words': 273}