0
  /   ˆ{‹„„-i[D<†ªoZƒ›Ù«Ã606_‘I|¥‰ÓMdœv ©ƒ†ü+=ÃÂ ^    ‹      Õ–]oÚ0†ïû+<_ìÚj4xêH¥¡µQ¦iš¦ÊÄ†XMìÈ6Púëçà´Í&Ð¨DQ{uŽ“7>ïãø+ü]÷Æ?‡èëøê¿¹ì÷®ühõ ¢qä_´ë� àb€N¬Í; Ëå²¾lÕ•žÁx‰ÍÒ6«ElëÌ2LŽÂâ9BaÂ)s…VØ”“¾dü©)5·F0Þ†\«l¢�°fx:­”³2ÀøBÄÜ¹åd<SzU†HÅx£l­Ó|WÊ¢áD±Uá%xÕº®û5 �¬Ë©&¡MÐ‚¦b&»Øª“Pd3dtÜÅ b%LR*ïê31Åˆ¦¶‹õ{×¿�Îy*¾&!EÎÜ´‹?÷ºƒ³ën„É€f<ºYså4ç˜\RcQ¦˜˜
Î¶Šo¼øF<lï0òšˆ›X‹Ü
%Ÿ¥à«¨±JMNë±#HtUå%ì£Aã¿cx>ºŒ£þÈ	+ºxv·¯¿ˆÉ�j.-Š„æ±uoJD_ï£œ˜üì±‰J -f‰Å¡Ú¨|õT¥Œë*÷6âG¿>V]þc«ÙhžÔ‚ |BÁi§q‚Ð+úŸË;©–²
à&ÅF %S!9&>î Ðl¢à¸4·¸méÛòdený¤Â¤Òx¯(¢ØK’uþV@v_¹Zrí…�ûðàE¡Ýn´(ÎLžÒ·ò^€a,µaÞŠýÝg‘™OÊ3Â!<åïp‹�ó…;Ë0ñq žGEGìöAIn0©4^Níx•�ò’Âúj‚¿æþÂèIžI    1   ˆl–Ü4ý( ©¤ýÔâ€vãA¸ÓªbÑ¿�þ@³Ž �:Qt¿ÏÆ0ÅÄÃ  5   	ˆl–Ým_JJi?u8 Eq�Üeõ1hß�þB g„Ñ�â²ßóÇƒh¹ÆÅÄ      	00000044
  Y   ˆl–Ðz¾”Šj"Tâ‚À½q¶”Å£�þBðˆ³�”�ÆèdzW�üÿÈƒp/=Ç_ŠI|¥�+Wé3ž¯a–Ým_JJi?u8 Z¸®¥1hßÇ ,    """
Tools for converting old- to new-style metadata.
"""

from __future__ import annotations

import functools
import itertools
import os.path
import re
import textwrap
from collections.abc import Generator, Iterable, Iterator
from email.message import Message
from email.parser import Parser
from typing import Literal

from packaging.requirements import Requirement


def _nonblank(str: str) -> bool | Literal[""]:
    return str and not str.startswith("#")


@functools.singledispatch
def yield_lines(iterable: Iterable[str]) -> Iterator[str]:
    r"""
    Yield valid lines of a string or iterable.
    >>> list(yield_lines(''))
    []
    >>> list(yield_lines(['foo', 'bar']))
    ['foo', 'bar']
    >>> list(yield_lines('foo\nbar'))
    ['foo', 'bar']
    >>> list(yield_lines('\nfoo\n#bar\nbaz #comment'))
    ['foo', 'baz #comment']
    >>> list(yield_lines(['foo\nbar', 'baz', 'bing\n\n\n']))
    ['foo', 'bar', 'baz', 'bing']
    """
    return itertools.chain.from_iterable(map(yield_lines, iterable))


@yield_lines.register(str)
def _(text: str) -> Iterator[str]:
    return filter(_nonblank, map(str.strip, text.splitlines()))


def split_sections(
    s: str | Iterator[str],
) -> Generator[tuple[str | None, list[str]], None, None]:
    """Split a string or iterable thereof into (section, content) pairs
    Each ``section`` is a stripped version of the section header ("[section]")
    and each ``content`` is a list of stripped lines excluding blank lines and
    comment-only lines.  If there are any such lines before the first section
    header, they're returned in a first ``section`` of ``None``.
    """
    section = None
    content: list[str] = []
    for line in yield_lines(s):
        if line.startswith("["):
            if line.endswith("]"):
                if section or content:
                    yield section, content
                section = line[1:-1].strip()
                content = []
            else:
                raise ValueError("Invalid section heading", line)
        else:
            content.append(line)

    # wrap up last segment
    yield section, content


def safe_extra(extra: str) -> str:
    """Convert an arbitrary string to a standard 'extra' name
    Any runs of non-alphanumeric characters are replaced with a single '_',
    and the result is always lowercased.
    """
    return re.sub("[^A-Za-z0-9.-]+", "_", extra).lower()


def safe_name(name: str) -> str:
    """Convert an arbitrary string to a standard distribution name
    Any runs of non-alphanumeric/. characters are replaced with a single '-'.
    """
    return re.sub("[^A-Za-z0-9.]+", "-", name)


def requires_to_requires_dist(requirement: Requirement) -> str:
    """Return the version specifier for a requirement in PEP 345/566 fashion."""
    if requirement.url:
        return " @ " + requirement.url

    requires_dist: list[str] = []
    for spec in requirement.specifier:
        requires_dist.append(spec.operator + spec.version)

    if requires_dist:
        return " " + ",".join(sorted(requires_dist))
    else:
        return ""


def convert_requirements(requirements: list[str]) -> Iterator[str]:
    """Yield Requires-Dist