]> git.ipfire.org Git - dbl.git/commitdiff
dnsbl: Use Babel to format the number of domains properly
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 09:58:37 +0000 (09:58 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 22 Dec 2025 10:01:38 +0000 (10:01 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
configure.ac
src/scripts/dnsbl.in

index f707debd3d21b18266d595f0d7744466055a1781..54ffd1601497b46fe1495021f4d2b6bf479dd09c 100644 (file)
@@ -52,6 +52,7 @@ AC_PROG_MKDIR_P
 # Python
 AM_PATH_PYTHON([3.13])
 
+AX_PYTHON_MODULE([babel], [fatal])
 AX_PYTHON_MODULE([httpx], [fatal])
 AX_PYTHON_MODULE([rich], [fatal])
 AX_PYTHON_MODULE([sqlmodel], [fatal])
index 841e63a058be82adb79652c3287dd31e88890060..e7ca4c6e490710dd972f4208832e2818695709ec 100644 (file)
@@ -20,6 +20,7 @@
 ###############################################################################
 
 import argparse
+import babel.numbers
 import dnsbl
 import dnsbl.exporters
 import logging
@@ -192,7 +193,7 @@ class CLI(object):
                table.add_column(_("Slug"))
                table.add_column(_("License"))
                table.add_column(_("Last Updated"))
-               table.add_column(_("Listed Unique Domains"))
+               table.add_column(_("Listed Unique Domains"), justify="right")
 
                # Show all lists
                for list in backend.lists:
@@ -201,7 +202,7 @@ class CLI(object):
                                list.slug,
                                list.license,
                                list.updated_at.isoformat() if list.updated_at else _("N/A"),
-                               "%s" % len(list),
+                               babel.numbers.format_decimal(len(list)),
                        )
 
                # Print the table
@@ -243,7 +244,7 @@ class CLI(object):
                table.add_row(_("License"), list.license)
                table.add_row(_("Created At"), list.created_at.isoformat())
                table.add_row(_("Created By"), list.created_by)
-               table.add_row(_("Listed Unique Domains"), "%s" % len(list))
+               table.add_row(_("Listed Unique Domains"), babel.numbers.format_decimal(len(list)))
 
                # Print list properties
                self.console.print(table)
@@ -255,7 +256,7 @@ class CLI(object):
                table.add_column(_("URL"))
                table.add_column(_("Created At"))
                table.add_column(_("Created_By"))
-               table.add_column(_("Listed Domains"))
+               table.add_column(_("Listed Domains"), justify="right")
 
                for source in list.sources:
                        table.add_row(
@@ -264,7 +265,7 @@ class CLI(object):
                                source.url,
                                source.created_at.isoformat(),
                                source.created_by,
-                               "%s" % len(source),
+                               babel.numbers.format_decimal(len(source)),
                        )
 
                # Print the sources