<commit_before># -*- coding: utf-8 -*-
"""Configuration management for hlama

Currently, there are three different possible sources for the dependencies
of HLA-MA.

- Assume that the software is available in $PATH
- The software is installed using Bioconda and in the environment
  hlama-$version
- The software is available using environment modules
"""

import configparser

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


class Configuration:
    """Helper class for accessing configuration"""

    @classmethod
    def load(klass, path):
        config = configparser.ConfigParser()
        config.read(path)
        return Configuration(config)

    def __init__(self, config):
        """Load configuration with values from the given path"""
        self.config = config

    @property
    def dep_source(self):
        return self.config.get('hlama', 'dep_source', fallback='in_path')

    def cmd_prefix(self):
        """Return necessary command prefix"""
        if self.dep_source == 'bioconda':
            prepend = self.config.get('hlama.bioconda', 'prepend_path')
            print(prepend)
            if prepend:
                prepend = 'export PATH={prepend}:$PATH'.format(
                    prepend=prepend)
            env = self.config.get('hlama.bioconda', 'env')
            if env:
                s = 'source activate {}'.format(env)
            else:
                s = 'echo "Error: not configured" 1>&2; exit 1;'
            return '# Load conda environment\n{}\n{}'.format(
                prepend if prepend else '', s)
        elif self.dep_source == 'environment_modules':
            s = self.config.get(
                'hlama.environment_modules', 'module_command',
                fallback='echo "Error not configured" 1>&2; exit 1;')
            return '# Load environment modules\n{}'.format(s)
        else:
            return '# Dependencies are assumed to be in env PATH'<commit_msg>Fixing bioconda prepend<commit_after># -*- coding: utf-8 -*-
"""Configuration management for hlama

Currently, there are three different possible sources for the dependencies
of HLA-MA.

- Assume that the software is available in $PATH
- The software is installed using Bioconda and in the environment
  hlama-$version
- The software is available using environment modules
"""

import configparser

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


class Configuration:
    """Helper class for accessing configuration"""

    @classmethod
    def load(klass, path):
        config = configparser.ConfigParser()
        config.read(path)
        return Configuration(config)

    def __init__(self, config):
        """Load configuration with values from the given path"""
        self.config = config

    @property
    def dep_source(self):
        return self.config.get('hlama', 'dep_source', fallback='in_path')

    def cmd_prefix(self):
        """Return necessary command prefix"""
        if self.dep_source == 'bioconda':
            prepend = self.config.get('hlama.bioconda', 'prepend_path')
            if prepend:
                prepend = 'export PATH={prepend}:$PATH; '.format(
                    prepend=prepend)
            env = self.config.get('hlama.bioconda', 'env')
            if env:
                s = '{}source activate {}'.format(
                prepend if prepend else '', env)
            else:
                s = 'echo "Error: not configured" 1>&2; exit 1;'
            return '# Load conda environment\n{}\n{}'.format(
                prepend if prepend else '', s)
        elif self.dep_source == 'environment_modules':
            s = self.config.get(
                'hlama.environment_modules', 'module_command',
                fallback='echo "Error not configured" 1>&2; exit 1;')
            return '# Load environment modules\n{}'.format(s)
        else:
            return '# Dependencies are assumed to be in env PATH'
{'fraction_non_alphanumeric': 0.11134127395132055, 'fraction_numerical': 0.0036250647332988087, 'mean_word_length': 2.3503902862098873, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, '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': '7610412', 'n_tokens_mistral': 1054, 'n_tokens_neox': 1006, 'n_words': 326}