nixos-configuration/pkgs/pretix/tlds-read-domains-from-file.patch
2023-02-22 02:24:06 +00:00

36 lines
1.1 KiB
Diff

From 40544e83b5920c84a4565c2bf8dc29fc381d5796 Mon Sep 17 00:00:00 2001
From: Jakob Lechner <mail@jalr.de>
Date: Tue, 21 Feb 2023 21:25:06 +0000
Subject: [PATCH] read static file
---
setup.py | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/setup.py b/setup.py
index 6b4653c..13b6ad4 100644
--- a/setup.py
+++ b/setup.py
@@ -8,16 +8,9 @@ from setuptools import setup, find_packages
if sys.version_info.major >= 3:
import urllib.request
- r = urllib.request.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt')
- assert r.status == 200
- data = r.read().decode('utf-8').split('\n')
-else:
- import urllib
-
- r = urllib.urlopen('https://data.iana.org/TLD/tlds-alpha-by-domain.txt')
- assert r.getcode() == 200
- data = r.read().split('\n')
-
+ with open("tlds-alpha-by-domain.txt", 'r') as f:
+ data = f.read().split('\n')
+
version = re.match('^# Version (?P<version>[0-9]+).*$', data[0]).group('version')
tlds = [i.lower() for i in data[1:] if i and not i.startswith('#')]
--
2.38.3