<commit_before>import sys
import re

from puppetenc import models
from puppetenc.config import Session

def get_host(host_name):
    host = Session().query(models.Host).filter_by(name=host_name).first()
    if host:
        return host
    else:
        hosts = Session().query(models.Host).all()
        for host in hosts:
            if re.match(host.name, host_name):
                return host
    if not host:
        # XXX: get default
        pass

def dump_yaml(host_name):
    host = get_host(host_name)
    return "classes:\n" + "\n".join(("  %s:" % puppetClass.name for puppetClass in host.classes))

if __name__ == '__main__':
    print dump_yaml(sys.argv[1])<commit_msg>Default group is read if no other host match<commit_after>import sys
import re

from puppetenc import models
from puppetenc.config import Session

def get_host(host_name):
    host = Session().query(models.Host).filter_by(name=host_name).first()
    if host:
        return host
    else:
        hosts = Session().query(models.Host).all()
        for host in hosts:
            if re.match(host.name, host_name):
                return host
    if not host:
        host = Session().query(models.Host).filter_by(name='default').first()

def dump_yaml(host_name):
    host = get_host(host_name)
    classes = []
    if host:
        classes = host.classes
    else:
        default_group = Session().query(models.Group).filter_by(name='default').first()
        if default_group:
            classes = default_group.classes
    return "classes:\n" + "\n".join(("  %s:" % puppetClass.name for puppetClass in classes))

if __name__ == '__main__':
    print dump_yaml(sys.argv[1])
{'fraction_non_alphanumeric': 0.11860325105358217, 'fraction_numerical': 0.0012040939193257074, 'mean_word_length': 2.838337182448037, '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': '879123', 'n_tokens_mistral': 514, 'n_tokens_neox': 503, 'n_words': 131}