Skip to content

Commit 660a52f

Browse files
committed
Skip null IANA updates
1 parent e329685 commit 660a52f

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

‎tooling/src/hypothesistooling/__main__.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
from datetime import datetime
2222
from glob import glob
2323
from urllib.parse import urlparse
24-
from urllib.request import urlretrieve
2524

2625
import hypothesistooling as tools
2726
import hypothesistooling.projects.conjecturerust as cr
2827
import hypothesistooling.projects.hypothesispython as hp
2928
import hypothesistooling.projects.hypothesisruby as hr
29+
import requests
3030
from coverage.config import CoverageConfig
3131
from hypothesistooling import installers as install, releasemanagement as rm
3232
from hypothesistooling.scripts import pip_tool
@@ -309,12 +309,15 @@ def update_python_versions():
309309

310310

311311
def update_vendored_files():
312-
for url in [
313-
# Turns out that as well as adding new gTLDs, IANA can *terminate* old ones
314-
"http://data.iana.org/TLD/tlds-alpha-by-domain.txt",
315-
]:
316-
fname = urlparse(url).path.split("/")[-1]
317-
urlretrieve(url, os.path.join(hp.PYTHON_SRC, "hypothesis", "vendor", fname))
312+
vendor = pathlib.Path(hp.PYTHON_SRC) / "hypothesis" / "vendor"
313+
314+
# Turns out that as well as adding new gTLDs, IANA can *terminate* old ones
315+
url = "http://data.iana.org/TLD/tlds-alpha-by-domain.txt"
316+
fname = vendor / urlparse(url).path.split("/")[-1]
317+
new = requests.get(url).content
318+
# If only the timestamp in the header comment has changed, skip the update.
319+
if fname.read_bytes().splitlines()[1:] != new.splitlines()[1:]:
320+
fname.write_bytes(new)
318321

319322

320323
@task()

0 commit comments

Comments
 (0)