From: Alexander Cecile Date: Thu, 20 Aug 2020 21:01:11 +0000 (-0400) Subject: Document get_file_by_url X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=44f41c317b08af936d3428298aac808e0e406fa4;p=stevenblack-hosts.git Document get_file_by_url --- diff --git a/updateHostsFile.py b/updateHostsFile.py index ad31a246b..81d1da820 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -1467,6 +1467,21 @@ def maybe_copy_example_file(file_path): def get_file_by_url(url, params=None, **kwargs): + """ + Retrieve the contents of the hosts file at a certain URL, then pass it through domain_to_idna(). + + Simple wrapper around the requests.get() function, uses the same parameters. + + Parameters + ---------- + url + params + kwargs + + Returns + ------- + content: str + """ req = requests.get(url=url, params=params, **kwargs) req.encoding = req.apparent_encoding res_text = "\n".join([domain_to_idna(line) for line in req.text.splitlines()])