|
21 | 21 | from datetime import datetime |
22 | 22 | from glob import glob |
23 | 23 | from urllib.parse import urlparse |
24 | | -from urllib.request import urlretrieve |
25 | 24 |
|
26 | 25 | import hypothesistooling as tools |
27 | 26 | import hypothesistooling.projects.conjecturerust as cr |
28 | 27 | import hypothesistooling.projects.hypothesispython as hp |
29 | 28 | import hypothesistooling.projects.hypothesisruby as hr |
| 29 | +import requests |
30 | 30 | from coverage.config import CoverageConfig |
31 | 31 | from hypothesistooling import installers as install, releasemanagement as rm |
32 | 32 | from hypothesistooling.scripts import pip_tool |
@@ -309,12 +309,15 @@ def update_python_versions(): |
309 | 309 |
|
310 | 310 |
|
311 | 311 | 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) |
318 | 321 |
|
319 | 322 |
|
320 | 323 | @task() |
|
0 commit comments