public inbox for [email protected]
help / color / mirror / Atom feedFrom: Florents Tselai <[email protected]>
To: Thomas Munro <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: ISBN range table
Date: Tue, 14 Apr 2026 18:32:47 +0300
Message-ID: <CA+v5N42+0S=PwLE_5qqHGPaTJuSWxfU2mw6LaDubJpL-nduhEQ@mail.gmail.com> (raw)
In-Reply-To: <CA+hUKGKkt5AcwmkAskvpx7YtXOTq0ntxA3wVa=3YFQNqMkaDVw@mail.gmail.com>
References: <CA+hUKG+-2=tq15fLm=MbJhCTA=i-XJ=ZDMWjiWUg_eGH9cfP2Q@mail.gmail.com>
<CA+hUKGKkt5AcwmkAskvpx7YtXOTq0ntxA3wVa=3YFQNqMkaDVw@mail.gmail.com>
On Tue, Apr 14, 2026 at 6:05 AM Thomas Munro <[email protected]> wrote:
> On Sun, Apr 12, 2026 at 11:37 PM Thomas Munro <[email protected]>
> wrote:
> > A recent-ish thread[1] made me wonder what that big table of data
> > does, and why we have a random update every decade or so, and I came
> > up with the attached.
>
> Fixed a couple of typos and added as commitfest #6676. The idea is
> that update_isbn.py would become another periodic update task, similar
> to Unicode, contrib/unaccent and the IANA timezone stuff. I suppose
> running it only for major releases would be enough for such
> non-critical data. There are also some other much smaller tables in
> this contrib module, but they don't seem to be moving (?) so I didn't
> look at them.
>
> I'm not volunteering today, but a passing thought I had while browsing
> this complicated code full of scary pointer arithmetic is that it
> might be an idea to try to describe the entire EAN3 number space in a
> much simpler single binary-searchable array that maps uint64_t ranges
> to TO_CHAR format strings, with entries that look something like:
>
> {9780037000000, 9780638999999, "999-9-99-999999-9"}
>
Nitpick; I'd just use standard python and avoid import requests .
Attachments:
[application/octet-stream] stdpy.diff (942B, 3-stdpy.diff)
download | inline diff:
diff --git a/contrib/isn/update_isbn.py b/contrib/isn/update_isbn.py
index 5b44b5c18ff..856a6828c5d 100644
--- a/contrib/isn/update_isbn.py
+++ b/contrib/isn/update_isbn.py
@@ -1,7 +1,8 @@
-# Update ISBN.h from primary source.
+#!/usr/bin/env python3
+# Update ISBN.h from primary source.
import re
-import requests
+from urllib.request import Request, urlopen
import xml.etree.ElementTree as ET
SOURCE_URL = "https://www.isbn-international.org/export_rangemessage.xml"
@@ -72,10 +73,9 @@ def generate_table(root, gs1_prefix):
return table_lines, index_lines
def fetch_and_parse_source_data():
- #return ET.parse('x.xml').getroot()
- response = requests.get(SOURCE_URL)
- response.raise_for_status()
- return ET.fromstring(response.text)
+ with urlopen(SOURCE_URL) as response:
+ data = response.read()
+ return ET.fromstring(data)
def merge_isbn(input_lines):
root = fetch_and_parse_source_data()
view thread (3+ messages)
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: ISBN range table
In-Reply-To: <CA+v5N42+0S=PwLE_5qqHGPaTJuSWxfU2mw6LaDubJpL-nduhEQ@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox