<commit_before># Copyright 2014 CloudFounders NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Native Injector module
"""
import os
from ConfigParser import RawConfigParser
from subprocess import check_output, CalledProcessError


class Injector(object):
    """
    Injector class, provides all logic to inject. However, the unittest injector
    only provides functionality required in the unittests
    """

    def __init__(self):
        """
        This class should be fully static
        """
        raise RuntimeError('This class should not be instantiated.')

    @staticmethod
    def inject_configuration(provider):
        """ Injects the Config module """
        def _get(key):
            filename, section, item = key.split('.', 2)
            config = RawConfigParser()
            config.read('/opt/OpenvStorage/config/{0}.cfg'.format(filename))
            return config.get(section, item)

        def _set(key, value):
            filename, section, item = key.split('.', 2)
            config = ConfigParser.RawConfigParser()
            config.read('/opt/OpenvStorage/config/{0}.cfg'.format(filename))
            config.set(section, item, value)
            with open('/opt/OpenvStorage/config/{0}.cfg'.format(filename), 'w') as config_file:
                config.write(config_file)

        def _get_int(key):
            return int(_get(key))

        provider.get = staticmethod(_get)<commit_msg>OVS-1714 - Fix for change to RawConfigParser<commit_after># Copyright 2014 CloudFounders NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Native Injector module
"""
import os
from ConfigParser import RawConfigParser
from subprocess import check_output, CalledProcessError


class Injector(object):
    """
    Injector class, provides all logic to inject. However, the unittest injector
    only provides functionality required in the unittests
    """

    def __init__(self):
        """
        This class should be fully static
        """
        raise RuntimeError('This class should not be instantiated.')

    @staticmethod
    def inject_configuration(provider):
        """ Injects the Config module """
        def _get(key):
            filename, section, item = key.split('.', 2)
            config = RawConfigParser()
            config.read('/opt/OpenvStorage/config/{0}.cfg'.format(filename))
            return config.get(section, item)

        def _set(key, value):
            filename, section, item = key.split('.', 2)
            config = RawConfigParser()
            config.read('/opt/OpenvStorage/config/{0}.cfg'.format(filename))
            config.set(section, item, value)
            with open('/opt/OpenvStorage/config/{0}.cfg'.format(filename), 'w') as config_file:
                config.write(config_file)

        def _get_int(key):
            return int(_get(key))

        provider.get = staticmethod(_get)
{'fraction_non_alphanumeric': 0.09716494845360825, 'fraction_numerical': 0.007731958762886598, 'mean_word_length': 2.904426559356137, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1355252', 'n_tokens_mistral': 1024, 'n_tokens_neox': 988, 'n_words': 360}