{% extends "_base.html" %}

{% block breadcrumbs %}
{% endblock breadcrumbs %}

{% block titlecontent -%}
    {{ (the_score * 100) | round(1) }}% →
    {{ (py2_score * 100) | round(1) }}% –
    {{ super() }}
{%- endblock titlecontent %}

{% block favicon_url -%}
    {{ url_for('piechart_svg') }}?{{ cache_tag }}
{%- endblock favicon_url %}

{% block style %}
    {{ super() }}
    @media (min-width: 768px) {
        .main-summary {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-evenly;
        }
        .main-summary .summary-sentence {
            font-size: 3rem;
            flex-grow: 1;
            position: relative;
            padding-left: 14rem;
            padding-right: 4rem;
        }
        .main-summary .big-percentage {
            display: block;
            position: absolute;
            left: 0;
            top: -0.5rem;
            padding: 0 1rem;
            font-size: 6rem;
            text-align: right;
            min-width: 14rem;
        }
        .main-summary .big-percentage .smaller {
            font-size: 3rem;
        }
        .main-summary .stuffing {
            font-size: 1.5rem;
            display: block;
            white-space: nowrap;
            line-height: 3rem;
        }
        .main-summary .callout {
            white-space: nowrap;
            line-height: 3rem;
        }
    }
{% endblock style %}

{% block bodycontent %}
    <div class="container">
        <div class="col-md-12">
            <h1>
                Python 2 Dropping Database
                {% if 'name' in config %}
                    <small>for {{ config['name'] }}</small>
                {% endif %}
            </h1>
        </div>
        <div class="col-md-12">
            {{ progress_summary(status_summary, total_pkg_count) }}
        </div>
        <div class="col-md-12">
            <div class="main-summary">
            <div class="summary-sentence">
                <span class="big-percentage"
                    style="color: {{ statuses['py3-only'].color }};"
                >
                    {% set score_parts = (the_score * 100) | split_digits(1) %}
                    {{ score_parts[0] -}}
                    <span class="smaller">.
                        {{- score_parts[1] -}}%
                    </span>
                </span>
                <span class="stuffing">
                    Python packages in Fedora Rawhide support
                </span>
                <span class="callout">Python 3 only.</span>
            </div>
            <div class="summary-sentence">
                <span class="big-percentage"
                    style="color: {{ statuses['released'].color }};"
                >
                    {% set score_parts = (py2_score * 100) | split_digits(1) %}
                    {{ score_parts[0] -}}
                    <span class="smaller">.
                        {{- score_parts[1] -}}%
                    </span>
                </span>
                <span class="stuffing">
                    Python packages in Fedora Rawhide support
                </span>
                <span class="callout">Python 3.</span>
            </div>
            </div>
        </div>
        <div class="col-md-8">
            {% if 'main-instructions' in config %}
                <p>
                {{ config['main-instructions']
                        .replace('$HOWTO_LINK', url_for('howto'))
                        .replace('$MISPACKAGED_LINK', '#mispackaged')
                    |safe }}
                </p>
            {% endif %}
            {% if groups %}
                <h2>Package Groups and FESCo exceptions</h2>
                <p>
                    For some groups of packages which are likely to need
                    <a href="https://fedoraproject.org/wiki/Changes/RetirePython2#The_python27_package">python27</a>
                    in Fedora 32+,
                    we track how many Python2-only packages they bring into
                    the system (including the current Python 2 dependencies).
                    <br>
                    This makes it possible to see how big the dependency tree is,
                    and possibly where it can be trimmed.
                </p>
                <div>
                    If you're considering an exception for your package,
                    let's talk at Bugzilla.
                    Open a bug for your package (or use an existing bug) and
                    make sure it:
                    <ul>
                        <li>blocks the
                            <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1698500">
                                F31_PY2REMOVAL
                            </a> bug,
                        </li>
                        <li>has <code>python-maint@redhat.com</code> in CC,</li>
                        <li>
                            answers the questions in <a href="https://fedoraproject.org/wiki/Changes/F31_Mass_Python_2_Package_Removal#Information_on_Remaining_Packages">the F31 Mass Python 2 Package Removal change</a>.
                        </li>
                    </ul>
                </div>
                <p>
                    (Some packages listed do not have a FESCo exception yet.
                    They <em>will</em> need one to stay in Fedora.)
                </p>
                <p>
                    Build dependencies are not yet tracked properly.
                </p>
                {% for grp, (py3, dual, py2) in groups %}
                    <div>
                        <td>
                        <a href="{{ url_for('group', grp=grp.ident) }}">
                            <img
                                src="{{ url_for('piechart_grp', grp=grp.ident) }}?{{ cache_tag }}"
                                style="width: 1em;"
                            >
                            {{ grp.name }}
                        </a>
                        {% if 'exception' in grp %}
                            –
                            <a href="{{ grp['exception'] }}">
                                {%- if grp.hidden -%}
                                    <small>exc. request</small>
                                {%- else -%}
                                    <i class="fa fa-thumb-tack"></i>
                                    <small>exc.</small>
                                {%- endif -%}
                            </a>
                        {% endif %}
                        –
                        {% set n = len(grp.seed_packages) + len(grp.untracked_packages) %}
                        {% if dual == py2 == 0 %}
                            {% if grp.packages %}
                                {{ n }} py3-only package{%if n != 1 %}s{% endif %}.
                            {% elif grp.untracked_packages %}
                                {{ n }} package{%if n != 1 %}s{% endif %} portingdb doesn't track.
                            {% else %}
                                No packages that portingdb tracks.
                            {% endif %}
                        {% else %}
                            {{ n }} package{%if n != 1 %}s{% endif %}
                            bringing in <strong>{{ dual+py2 }}</strong> Python 2 packages.
                        {% endif %}
                    </div>
                {% endfor %}
            {% endif %}
            {% if mispackaged_packages %}
                <h2 id="mispackaged">Mispackaged packages</h2>
                <div>
                    {{ len(mispackaged_packages) }} packages were found to have some kind of packaging problem.
                </div>
                <ul class="simple-pkg-list">
                {% for pkg in mispackaged_packages %}
                    <li>
                        <div title="{{ pkg.note }}">{{ pkglink(pkg) }}</div>
                    </li>
                {% endfor %}
                </ul>

            {% endif %}
            <h2 id="idle">Idle packages</h2>
            <div>
                {{ len(ready_packages) }} packages are not ported to Python 3 yet.
                Grab your favorite, and go port it!
            </div>
            <div>
                If you're not sure which one to pick, or if you just want to help,
                choose one on which lots of other stuff depends.
            </div>
            <ul class="simple-pkg-list">
                {% for pkg in ready_packages %}
                   <li>
                        {{ pkglink(pkg) }}
                        {% if pkg.pending_dependents %}
                           (needed for
                                {% for req in pkg.pending_dependents.values() -%}
                                   {{- pkglink_text(req) -}}
                                   {{- orphan_badge(req) -}}
                                   {{- exception_badge(req) -}}
                                   {%- if not loop.last %}, {% endif -%}
                                {%- endfor -%})
                        {% endif %}
                   </li>
                {% endfor %}
            </ul>
            <h2 id="blocked">Blocked packages</h2>
            <div>
                {{ len(blocked_packages) }}  packages don't have all dependencies ported to Python 3 yet.
            </div>
            <div>
                (Or they could be false positives – check the package before giving up on it!)
            </div>
            <ul class="simple-pkg-list">
               {% for pkg in blocked_packages %}
                   <li>
                        {{ pkglink(pkg) }}
                        {% if pkg.pending_deps %}
                           (needs
                               {% for req in pkg.pending_deps.values() -%}
                                   {{- pkglink_text(req) -}}
                                   {{- orphan_badge(req) -}}
                                   {{- exception_badge(req) -}}
                                   {%- if not loop.last %}, {% endif -%}
                                {%- endfor -%})
                        {% endif %}
                   </li>
               {% endfor %}
            </ul>
            <h2 id="released">Packages with dual support</h2>
            <div>
                {{ len(released_packages) }} packages support both Python 2 and 3.
                Half-way there!
            </div>
            <div>
               {% for pkg in released_packages %}
                    {{ pkglink(pkg) }}
               {% endfor %}
            </div>
            <h2 id="legacy-leaf">Packages with leaf Python 2 subpackages</h2>
            <div>
                The Python 2 versions of {{ len(legacy_leaf_packages) }} packages
                are not required by anything else we track.
                The subpackages can be dropped if the maintainer wishes.
            </div>
            <div>
               {% for pkg in legacy_leaf_packages %}
                    {{ pkglink(pkg) }}
               {% endfor %}
            </div>
            <h2 id="py3-only">Python3-only packages</h2>
            <div>
                {{ len(py3_only_packages) }} packages support Python 3 only. Yay!
            </div>
            <div>
               {% for pkg in py3_only_packages %}
                    {{ pkglink(pkg) }}
               {% endfor %}
            </div>
            <h2 id="dropped">Dropped packages</h2>
            <div>
                {{ len(dropped_packages) }}  packages will not be ported to Python 3.
                Anything that requires them will need to switch to an alternative.
                The suggested replacement is usually mentioned in porting notes;
                click on the package for more information.
            </div>
            <div>
               {% for pkg in dropped_packages %}
                    {{ pkglink(pkg) }}
               {% endfor %}
            </div>
        </div>
        <div class="col-md-1">
        </div>
        <div class="col-md-3">
            {% if 'load_time' in config %}
                <div>
                    Data for this site was loaded at:
                </div>
                <div class="text-center">
                    <tt>
                        {{ config['load_time'] }}
                    </tt>
                </div>
                <p>
                    <small>
                        Ignoring loading time and delays in repository mirrors,
                        it's current for that time.
                    </small>
                </p>
            {% endif %}
            <h2>Status Legend</h2>
            <ul class="list-group">
                {% for status, num_packages in statuses.items() %}
                    {% set status = statuses[status] %}
                    {% if num_packages %}
                        <li class="list-group-item">
                            {{ status_badge(status) }}
                            <a href="#{{ status.ident }}">{{ status.name }}</a>
                            <div><small>{{ status.description }}</small></div>
                        </li>
                    {% endif %}
                {% endfor %}
            </ul>
            <div>
                Package status is retreived periodically, so it might be
                slightly out of date.
            </div>
            <div>
                Individual package pages list the RPM
                versions this report is based on.
            </div>
            {% if 'extra-sidebar' in config %}
                {{ config['extra-sidebar'] |safe }}
            {% endif %}
            <h2>Visualizations</h2>
            <div>
                You might want to see an interactive
                <a href="{{ url_for('graph') }}">dependency graph</a>
                of all packages that still need Python 2 (Warning: CPU-hungry.)
            </div>
            <div>
                There is a
                <a href="{{ url_for('history') }}">graph of the history</a>
                of package statuses over this portingdb's lifetime.
            </div>
            <div>
                We also have a manager-friendly pie chart:
                <a href="{{ url_for('piechart_svg') }}">
                <img src="{{ url_for('piechart_svg') }}"></a>
            </div>
        </div>
    </div>
{% endblock bodycontent %}
