Skip to content

Instantly share code, notes, and snippets.

@emberian
Forked from Grissess/xfrm.py
Last active January 17, 2024 21:22
Show Gist options
  • Save emberian/8e2c4f9037939dd86e654acf8b8d46d6 to your computer and use it in GitHub Desktop.
Save emberian/8e2c4f9037939dd86e654acf8b8d46d6 to your computer and use it in GitHub Desktop.
import sys
from collections import defaultdict
hosts_by_pkg = defaultdict(set)
for line in sys.stdin:
line = line.strip()
if not line:
continue
host, pkg = line.split()
hosts_by_pkg[pkg].add(host)
for pkg, hosts in hosts_by_pkg.items():
init = f'{pkg}: '
print(init + ', '.join(hosts))
print()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment