<commit_before>from jinja2 import Template

import yaml


def yaml_to_md(table):
    out.write('## ' + table + '\n\n')
    for data in yaml.load_all(inp):
        key1 = data['layers'][table]['attributes'].keys()
        dicts = data['layers'][table]['attributes']
        dicts2 = dicts['type']['values']
        key2 = dicts2.keys()

        with open('templates/layer_attributes.md.jinja2') as f:
            t2 = Template(f.read())
        out.write(t2.render(mylist1=key1, a1=len(key1), space=' ', dicts=dicts))

        if 'correlated_attributes' in dicts2[key2[0]].keys():
            with open('templates/attribute_values_with_aggtype.md.jinja2') as f:
                type_table = f.read()
        else:
            with open('templates/attribute_values.md.jinja2') as f:
                type_table = f.read()

        t3 = Template(type_table)
        out.write(t3.render(typelist=key2, a=len(key2), dicts=dicts2))
        out.write('\n\n')


f = open("osmaxx_schema.yaml", 'r')
inp = f.read()
out = open("documentation.md", 'w')
yaml_to_md('adminarea_a')
yaml_to_md('building_a')
yaml_to_md('geoname_p')
yaml_to_md('landuse_a')
yaml_to_md('military_p')
yaml_to_md('misc_l')
yaml_to_md('natural_a')
yaml_to_md('nonop_l')
yaml_to_md('poi_p')
yaml_to_md('pow_p')
yaml_to_md('railway_bridge_l')
yaml_to_md('road_ground_l')
yaml_to_md('route_l')
yaml_to_md('traffic_a')
yaml_to_md('traffic_p')
yaml_to_md('transport_a')
yaml_to_md('utility_a')
yaml_to_md('utility_p')
yaml_to_md('utility_l')
yaml_to_md('water_a')
yaml_to_md('water_p')
yaml_to_md('water_l')
<commit_msg>use yaml.load instead of yaml.load_all<commit_after>from jinja2 import Template

import yaml


def yaml_to_md(table):
    out.write('## ' + table + '\n\n')
    data = yaml.load(inp)

    key1 = data['layers'][table]['attributes'].keys()
    dicts = data['layers'][table]['attributes']
    dicts2 = dicts['type']['values']
    key2 = dicts2.keys()

    with open('templates/layer_attributes.md.jinja2') as f:
        t2 = Template(f.read())
    out.write(t2.render(mylist1=key1, a1=len(key1), space=' ', dicts=dicts))

    if 'correlated_attributes' in dicts2[key2[0]].keys():
        with open('templates/attribute_values_with_aggtype.md.jinja2') as f:
            type_table = f.read()
    else:
        with open('templates/attribute_values.md.jinja2') as f:
            type_table = f.read()

    t3 = Template(type_table)
    out.write(t3.render(typelist=key2, a=len(key2), dicts=dicts2))
    out.write('\n\n')


f = open("osmaxx_schema.yaml", 'r')
inp = f.read()
out = open("documentation.md", 'w')
yaml_to_md('adminarea_a')
yaml_to_md('building_a')
yaml_to_md('geoname_p')
yaml_to_md('landuse_a')
yaml_to_md('military_p')
yaml_to_md('misc_l')
yaml_to_md('natural_a')
yaml_to_md('nonop_l')
yaml_to_md('poi_p')
yaml_to_md('pow_p')
yaml_to_md('railway_bridge_l')
yaml_to_md('road_ground_l')
yaml_to_md('route_l')
yaml_to_md('traffic_a')
yaml_to_md('traffic_p')
yaml_to_md('transport_a')
yaml_to_md('utility_a')
yaml_to_md('utility_p')
yaml_to_md('utility_l')
yaml_to_md('water_a')
yaml_to_md('water_p')
yaml_to_md('water_l')

{'fraction_non_alphanumeric': 0.16817010309278352, 'fraction_numerical': 0.014175257731958763, 'mean_word_length': 4.676416819012797, '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': '1007081', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1245, 'n_words': 174}