<commit_before>def _get_spack(pillars=None):
    from os.path import join, expanduser
    if pillars is None:
        pillars = __pillar__
    if 'spack' not in pillars:
        return {
          'directory': __grains__['userhome'] + "/spack",
          'config_dir': __grains__['userhome'] + ".spack",
          'compiler': 'clang@7.0.3'
        }
    return pillars['spack']

def _create_package_name(name, version=None, options=None, compiler=None):
    result = name
    if version:
        result += "@" + version
    if isinstance(options, str):
        result += " " + options
    elif options is not None:
        result += " " + " ".join(options)
    if compiler is not None:
        result += " %" + compiler
    return result

def installed(name, compiler=None, options=None, version=None, dependencies=None,
          **kwargs):
    from os.path import join
    defaults = _get_spack(__pillar__)
    specs = _create_package_name(
        name, version=version, options=options, compiler=compiler)
    if isinstance(dependencies, str):
        specs += " " + dependencies
    elif isinstance(dependencies, list):
        specs += " " + " ".join(dependencies)
    elif dependencies is not None:
        for package in dependencies:
            specs += _create_package_name(**package)
    spacker = join(defaults['directory'], 'bin', 'spack')
    return __states__['cmd.run'](spacker + " install " + specs)

def recipe(name, file=None):
    from os.path import join
    defaults = _get_spack(__pillar__)
    prefix = join(defaults['directory'], 'var', 'spack', 'packages', name)
    source = 'salt://spack/' + (name if file is None else file)
    results = {}
    results.update(__states__['file.directory'](prefix))
    results.update(
        __states__['file.managed'](join(prefix, 'package.py'), source=source))
    return results

def add_repo(name, github=None, scope=None, prefix=None):
    from os.path import expanduser, join

    ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
    target = __salt__['spack.repo_path'](name)

    if github is not None:
        spackdir = __salt__['pillar.get']('spack:directory', expanduser(join("~", "spack")))
        __states__['github.latest'](name=github, target=target)

    if __salt__['spack.repo_exists'](target):
        ret['result'] = True
        ret['comment'] = 'System already in the correct state'
        return ret

    ret['changes'] = {
        'old': 'repo not found',
        'new': '%s installed at %s' % (
            name if github is None else github, target)
    }
    if __opts__['test'] == True:
        ret['comment'] = 'The state of "{0}" will be changed.'.format(name)
        ret['result'] = None
        return ret

    __salt__['spack.add_repo'](target)
    ret['comment'] = 'Spack repo "{0}" installed.'.format(name)<commit_msg>Do not need spack.recipe anymore<commit_after>def _get_spack(pillars=None):
    from os.path import join, expanduser
    if pillars is None:
        pillars = __pillar__
    if 'spack' not in pillars:
        return {
          'directory': __grains__['userhome'] + "/spack",
          'config_dir': __grains__['userhome'] + ".spack",
          'compiler': 'clang@7.0.3'
        }
    return pillars['spack']

def _create_package_name(name, version=None, options=None, compiler=None):
    result = name
    if version:
        result += "@" + version
    if isinstance(options, str):
        result += " " + options
    elif options is not None:
        result += " " + " ".join(options)
    if compiler is not None:
        result += " %" + compiler
    return result

def installed(name, compiler=None, options=None, version=None, dependencies=None,
          **kwargs):
    from os.path import join
    defaults = _get_spack(__pillar__)
    specs = _create_package_name(
        name, version=version, options=options, compiler=compiler)
    if isinstance(dependencies, str):
        specs += " " + dependencies
    elif isinstance(dependencies, list):
        specs += " " + " ".join(dependencies)
    elif dependencies is not None:
        for package in dependencies:
            specs += _create_package_name(**package)
    spacker = join(defaults['directory'], 'bin', 'spack')
    return __states__['cmd.run'](spacker + " install " + specs)

def add_repo(name, github=None, scope=None, prefix=None):
    from os.path import expanduser, join

    ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''}
    target = __salt__['spack.repo_path'](name)

    if github is not None:
        spackdir = __salt__['pillar.get']('spack:directory', expanduser(join("~", "spack")))
        __states__['github.latest'](name=github, target=target)

    if __salt__['spack.repo_exists'](target):
        ret['result'] = True
        ret['comment'] = 'System already in the correct state'
        return ret

    ret['changes'] = {
        'old': 'repo not found',
        'new': '%s installed at %s' % (
            name if github is None else github, target)
    }
    if __opts__['test'] == True:
        ret['comment'] = 'The state of "{0}" will be changed.'.format(name)
        ret['result'] = None
        return ret

    __salt__['spack.add_repo'](target)
    ret['comment'] = 'Spack repo "{0}" installed.'.format(name)
{'fraction_non_alphanumeric': 0.14380572946309997, 'fraction_numerical': 0.0018971732119142477, 'mean_word_length': 2.975867269984917, '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': '7009761', 'n_tokens_mistral': 1632, 'n_tokens_neox': 1584, 'n_words': 417}