<commit_before>import os
from subprocess import Popen, PIPE
from genes.lib.traits import if_any
from genes.ubuntu.traits import is_ubuntu
from genes.debian.traits import is_debian


# TODO: stop using sudo or ensure it exists
# TODO: specify user to run as
# TODO: utilize functools partial to handle some of the above functionality
class Config:
    SET_SELECTIONS = ['debconf-set-selections']
    ENV = os.environ.copy()
    ENV['DEBIAN_FRONTEND'] = "noninteractive"


@if_any(is_debian(), is_ubuntu())
def set_selections(*selections):
    if selections:
        debconf = Popen(Config.SET_SELECTIONS, env=Config.ENV, stdin=PIPE)
        debconf.communicate(input=" ".join(selections))
        # FIXME: capture errors above, report them
    else:
        # FIXME: add error
        pass<commit_msg>Change bools to functions in if_any<commit_after>import os
from subprocess import Popen, PIPE
from genes.lib.traits import if_any
from genes.ubuntu.traits import is_ubuntu
from genes.debian.traits import is_debian


# TODO: stop using sudo or ensure it exists
# TODO: specify user to run as
# TODO: utilize functools partial to handle some of the above functionality
class Config:
    SET_SELECTIONS = ['debconf-set-selections']
    ENV = os.environ.copy()
    ENV['DEBIAN_FRONTEND'] = "noninteractive"


@if_any(is_debian, is_ubuntu)
def set_selections(*selections):
    if selections:
        debconf = Popen(Config.SET_SELECTIONS, env=Config.ENV, stdin=PIPE)
        debconf.communicate(input=" ".join(selections))
        # FIXME: capture errors above, report them
    else:
        # FIXME: add error
        pass
{'fraction_non_alphanumeric': 0.08776266996291718, 'fraction_numerical': 0.0, 'mean_word_length': 3.9359756097560976, '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': '6846215', 'n_tokens_mistral': 527, 'n_tokens_neox': 490, 'n_words': 154}