<commit_before><%inherit file="/base.mako"/>
<%namespace name="lib" file="lib.mako"/>
<%! from splinext.pokedex import i18n %>\

<%def name="title()">${_("%s - Locations") % c.location_name}</%def>

<%def name="title_in_page()">
<ul id="breadcrumbs">
    <li><a href="${url('/dex')}">${_(u'Pokédex')}</a></li>
    <li>${_(u'Locations')}</li>
    <li>${c.location_name}</li>
</ul>
</%def>

<h1>${c.location_name}</h1>

% for region, areas in h.keysort(c.region_areas, lambda x: -x.id):

<h2 id="region:${region.name}">
    <a href="#region:${region.name}" class="subtle">${region.name}</a>
</h2>

% for location_area in sorted(areas, key=lambda x: x.name):
% if location_area.name:
<h3 id="area:${location_area.name}">
    <a href="#area:${location_area.name}" class="subtle">${location_area.name}</a>
</h3>
% endif

<table class="dex-encounters striped-rows">
    ## Spit out <col> tags.  Zip cleverness lets us compare the current version
    ## to the one before it
    <col class="dex-col-name">
    % for version, prior_version in zip( \
        c.group_versions[location_area], \
        [None] + c.group_versions[location_area] \
    ):
    % if not prior_version or prior_version.version_group.generation \
                                 != version.version_group.generation:
    <col class="dex-col-encounter-version dex-col-first-version">
    % else:
    <col class="dex-col-encounter-version">
    % endif
    % endfor

    ## Draw a divider to separate method, in id order.  Why not?
    ## Include the versions header, too.
    % for method, pokemon_version_condition_encounters \
       in h.keysort(c.grouped_encounters.get(location_area, {}), lambda k: k.id):

    <tr class="header-row">
        <th></th>
        % for version in c.group_versions[location_area]:
        <th>${h.pokedex.version_icons(version)} ${version.name}</th>
        % endfor
    </tr>
    <tr class="subheader-row">
        <th colspan="100">
            ${h.pokedex.chrome_img('encounters/' + c.encounter_method_icons.get(method.identifier, 'unknown.png'))}
            ${method.name}
        </th>
    </tr>

    ## One row per Pokémon, sorted by name
    % for pokemon, version_condition_encounters \
       in h.keysort(pokemon_version_condition_encounters, lambda k: k.name):
    <tr>
        <th class="location">
            ${h.pokedex.pokemon_link(
                pokemon,
                h.literal(u"""{0} {1}""".format(
                    lib.pokemon_icon(pokemon),
                    pokemon.name,
                )),
                class_='dex-icon-link',
            )}
        </th>
        % for version in c.group_versions[location_area]:
        <% condition_encounters = version_condition_encounters[version] %>
        <td>
            ## Sort conditions by number of conditions (so "default" comes
            ## first, and simple before complex), then just by condition id.
            ## Conditions are only grouped in the first place so we can stick
            ## them in this div wrapper, which draws a divider line between
            ## them.
            % for conditions, condition_value_encounters in h.keysort( \
                condition_encounters, lambda k: [len(k)] + [cond.id for cond in k]):
            <div class="dex-encounter-condition-group">

            ## Sort in order of condition value id, too.  Pretty arbitrary, but
            ## the condition values are entirely under my control, and the
            ## order in the db is intuitive to me.
            % for condition_values, encounters in h.keysort( \
                condition_value_encounters, lambda k: [cv.id for cv in k]):
            <div class="dex-encounter-conditions">
                % for condition_value in condition_values:
                <div class="dex-encounter-icon">
                    ${h.pokedex.chrome_img('encounters/' \
                                            + c.encounter_condition_value_icons.get(condition_value.identifier, 'unknown.png'), \
                                            alt=condition_value.name, \
                                            title=condition_value.name)}<commit_msg>locations: Link pokemon icons properly<commit_after><%inherit file="/base.mako"/>
<%namespace name="lib" file="lib.mako"/>
<%! from splinext.pokedex import i18n %>\

<%def name="title()">${_("%s - Locations") % c.location_name}</%def>

<%def name="title_in_page()">
<ul id="breadcrumbs">
    <li><a href="${url('/dex')}">${_(u'Pokédex')}</a></li>
    <li>${_(u'Locations')}</li>
    <li>${c.location_name}</li>
</ul>
</%def>

<h1>${c.location_name}</h1>

% for region, areas in h.keysort(c.region_areas, lambda x: -x.id):

<h2 id="region:${region.name}">
    <a href="#region:${region.name}" class="subtle">${region.name}</a>
</h2>

% for location_area in sorted(areas, key=lambda x: x.name):
% if location_area.name:
<h3 id="area:${location_area.name}">
    <a href="#area:${location_area.name}" class="subtle">${location_area.name}</a>
</h3>
% endif

<table class="dex-encounters striped-rows">
    ## Spit out <col> tags.  Zip cleverness lets us compare the current version
    ## to the one before it
    <col class="dex-col-name">
    % for version, prior_version in zip( \
        c.group_versions[location_area], \
        [None] + c.group_versions[location_area] \
    ):
    % if not prior_version or prior_version.version_group.generation \
                                 != version.version_group.generation:
    <col class="dex-col-encounter-version dex-col-first-version">
    % else:
    <col class="dex-col-encounter-version">
    % endif
    % endfor

    ## Draw a divider to separate method, in id order.  Why not?
    ## Include the versions header, too.
    % for method, pokemon_version_condition_encounters \
       in h.keysort(c.grouped_encounters.get(location_area, {}), lambda k: k.id):

    <tr class="header-row">
        <th></th>
        % for version in c.group_versions[location_area]:
        <th>${h.pokedex.version_icons(version)} ${version.name}</th>
        % endfor
    </tr>
    <tr class="subheader-row">
        <th colspan="100">
            ${h.pokedex.chrome_img('encounters/' + c.encounter_method_icons.get(method.identifier, 'unknown.png'))}
            ${method.name}
        </th>
    </tr>

    ## One row per Pokémon, sorted by name
    % for pokemon, version_condition_encounters \
       in h.keysort(pokemon_version_condition_encounters, lambda k: k.name):
    <tr>
        <th class="location">
            ${h.pokedex.pokemon_link(
                pokemon,
                h.literal(u"""{0} {1}""".format(
                    capture(lib.pokemon_icon, pokemon),
                    pokemon.name,
                )),
                class_='dex-icon-link',
            )}
        </th>
        % for version in c.group_versions[location_area]:
        <% condition_encounters = version_condition_encounters[version] %>
        <td>
            ## Sort conditions by number of conditions (so "default" comes
            ## first, and simple before complex), then just by condition id.
            ## Conditions are only grouped in the first place so we can stick
            ## them in this div wrapper, which draws a divider line between
            ## them.
            % for conditions, condition_value_encounters in h.keysort( \
                condition_encounters, lambda k: [len(k)] + [cond.id for cond in k]):
            <div class="dex-encounter-condition-group">

            ## Sort in order of condition value id, too.  Pretty arbitrary, but
            ## the condition values are entirely under my control, and the
            ## order in the db is intuitive to me.
            % for condition_values, encounters in h.keysort( \
                condition_value_encounters, lambda k: [cv.id for cv in k]):
            <div class="dex-encounter-conditions">
                % for condition_value in condition_values:
                <div class="dex-encounter-icon">
                    ${h.pokedex.chrome_img('encounters/' \
                                            + c.encounter_condition_value_icons.get(condition_value.identifier, 'unknown.png'), \
                                            alt=condition_value.name, \
                                            title=condition_value.name)}
{'fraction_non_alphanumeric': 0.14051578693661124, 'fraction_numerical': 0.0031332851289467343, 'mean_word_length': 2.298489666136725, 'pattern_counts': {'":': 0, '<': 103, '<?xml version=': 0, '>': 103, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883567', 'n_tokens_mistral': 2554, 'n_tokens_neox': 2497, 'n_words': 584}