<commit_before>#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-


from __future__ import with_statement

__author__ = '<NAME> <<EMAIL>>'


import fcntl
import os
import socket
import struct
import ConfigParser

import vmcheckerpaths


DATE_FORMAT = '%Y.%m.%d %H:%M:%S'

_config = None
_tester_config = None


def config_reader(config_file):
    """Returns a RawConfigParser for the speciffied file."""
    config = ConfigParser.RawConfigParser()
    with open(config_file) as handle:
        config.readfp(handle)
    return config


def config():
    """Returns a RawConfigParser containing vmchecker's configuration."""
    global _config
    if _config is None:
        _config = config_reader(vmcheckerpaths.config_file())
    return _config


def config_variables(config_file, section_name):
    """Return a dictionary with values from the config_path file.

    NB:  the keys will be all lowercase!
    """
    config = config_reader(config_file)
    return dict(config.items(section_name))


def tester_config():
    """Returns a RawConfigParser with vmchecker tester's configuration."""
    global _tester_config
    if _tester_config is None:
        _tester_config = ConfigParser.RawConfigParser()
        with open(vmcheckerpaths.tester_config_file()) as handle:
            _tester_config.readfp(handle)
    return _tester_config


def relative_path(*args):
    """Joins the arguments and returns a path relative to root"""
    return os.path.join(vmcheckerpaths.root(), os.path.join(*args))


def get_ip_address(ifname):
    """Returns ip address for network interface 'ifname'
    in standard dotted notation.

    Source from:
        http://code.activestate.com/recipes/439094/
    """
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    return socket.inet_ntoa(fcntl.ioctl(
        s.fileno(),
        0x8915,  # SIOCGIFADDR
        struct.pack('256s', ifname[:15]))[20:24])


def repository():
    """Returns repository path"""
    return vmcheckerpaths.abspath(config().get('DEFAULT', 'Repository'))<commit_msg>pylint misc.py + remove unused code<commit_after>#! /usr/bin/env python2.5
# -*- coding: utf-8 -*-
"""Vmchecker configuration file readers"""

from __future__ import with_statement

__author__ = '<NAME> <<EMAIL>>'


import ConfigParser

import vmcheckerpaths


DATE_FORMAT = '%Y.%m.%d %H:%M:%S'

_config = None
_tester_config = None


def config_reader(config_file):
    """Returns a RawConfigParser for the speciffied file."""
    config_ = ConfigParser.RawConfigParser()
    with open(config_file) as handle:
        config_.readfp(handle)
    return config_


def config():
    """Returns a RawConfigParser containing vmchecker's configuration."""
    global _config
    if _config is None:
        _config = config_reader(vmcheckerpaths.config_file())
    return _config


def config_variables(config_file, section_name):
    """Return a dictionary with values from the config_path file.

    NB:  the keys will be all lowercase!

    """
    config_ = config_reader(config_file)
    return dict(config_.items(section_name))


def tester_config():
    """Returns a RawConfigParser with vmchecker tester's configuration."""
    global _tester_config
    if _tester_config is None:
        _tester_config = ConfigParser.RawConfigParser()
        with open(vmcheckerpaths.tester_config_file()) as handle:
            _tester_config.readfp(handle)
    return _tester_config



def repository():
    """Returns repository path"""
    return vmcheckerpaths.abspath(config().get('DEFAULT', 'Repository'))
{'fraction_non_alphanumeric': 0.10703191188929681, 'fraction_numerical': 0.0073425585992657446, 'mean_word_length': 3.8256130790190737, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '5057329', 'n_tokens_mistral': 1107, 'n_tokens_neox': 1058, 'n_words': 284}