inwx_domains_owner: Summen je Gruppe und TLD unter den Domains
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ am Ende separat aufgeführt.
|
|||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from collections import Counter
|
||||||
|
|
||||||
from inwx_common import get_client, call_api
|
from inwx_common import get_client, call_api
|
||||||
|
|
||||||
@@ -112,6 +113,21 @@ def get_group(domain):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def tld_of(domain):
|
||||||
|
"""Liefert die Top-Level-Domain (Teil hinter dem letzten Punkt)."""
|
||||||
|
return domain.rsplit('.', 1)[-1].lower() if '.' in domain else domain.lower()
|
||||||
|
|
||||||
|
|
||||||
|
def print_group_sums(recs, ziffer):
|
||||||
|
"""Gibt für eine Gruppe die Anzahl Domains pro Top-Level-Domain aus.
|
||||||
|
|
||||||
|
Eine Zeile je TLD im Format <ziffer> <tld> <anzahl>, z.B. '10 de 1'.
|
||||||
|
"""
|
||||||
|
counts = Counter(tld_of(r['name']) for r in recs)
|
||||||
|
for tld, anzahl in sorted(counts.items()):
|
||||||
|
print(f" {ziffer} {tld} {anzahl}")
|
||||||
|
|
||||||
|
|
||||||
def format_domain_line(rec):
|
def format_domain_line(rec):
|
||||||
"""Einzeilige Darstellung einer Domain (eingerückt unter der Gruppe)."""
|
"""Einzeilige Darstellung einer Domain (eingerückt unter der Gruppe)."""
|
||||||
if rec['ns'] is None:
|
if rec['ns'] is None:
|
||||||
@@ -158,6 +174,7 @@ def main():
|
|||||||
if matching:
|
if matching:
|
||||||
for rec in matching:
|
for rec in matching:
|
||||||
print(format_domain_line(rec))
|
print(format_domain_line(rec))
|
||||||
|
print_group_sums(matching, ziffer) # Summe direkt unter den Domains
|
||||||
else:
|
else:
|
||||||
print(" (keine Domains)")
|
print(" (keine Domains)")
|
||||||
print() # Leerzeile zwischen den Gruppen
|
print() # Leerzeile zwischen den Gruppen
|
||||||
@@ -170,6 +187,7 @@ def main():
|
|||||||
ziffer = rec['ziffer']
|
ziffer = rec['ziffer']
|
||||||
hinweis = "" if ziffer is None else f" [citeq:{ziffer} unbekannt]"
|
hinweis = "" if ziffer is None else f" [citeq:{ziffer} unbekannt]"
|
||||||
print(format_domain_line(rec) + hinweis)
|
print(format_domain_line(rec) + hinweis)
|
||||||
|
print_group_sums(rest, "-") # Summe direkt unter den Domains
|
||||||
print()
|
print()
|
||||||
|
|
||||||
print(f"Gesamt: {len(records)} Domain(s)")
|
print(f"Gesamt: {len(records)} Domain(s)")
|
||||||
|
|||||||
Reference in New Issue
Block a user