INNER CODE UNIT · Python

by_region

WMAL/kodachios · Kodachi-OS-10-stable/open/dock/lib/kodachi_countries.py:116

def by_region(universe=None):
    """Group a country universe into regions, in REGION_ORDER, without repeats.

    A country can sit in several groups, high-volume overlaps every region, so
    membership is resolved in REGION_ORDER and whatever is left over lands in a
    final bucket rather than being dropped. `universe` defaults to the
    exit-capable list; the exclude window passes the wider EXCLUDABLE set so a
    country with no exits still gets a row.
    """
    universe = set(universe or ALL)
    placed, out = set(), []
    for group in REGION_ORDER:
        members = [c for c in sorted(GROUPS[group]) if c in universe and c not in placed]
        placed |= set(members)
        if members:
            out.append((REGION_LABEL[group], members))
    rest = sorted(c for c in universe if c not in placed)
    if rest:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…