git.99rst.org
/
stevenblack-hosts.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
| inline |
side by side
(parent:
0f727b8
)
Use 'with' to not leave a resource open
author
Max G
<redacted>
Sat, 11 Jul 2020 10:58:44 +0000
(13:58 +0300)
committer
Max G
<redacted>
Sat, 11 Jul 2020 10:58:44 +0000
(13:58 +0300)
updateHostsFile.py
patch
|
blob
|
history
diff --git
a/updateHostsFile.py
b/updateHostsFile.py
index 8eaff17177ca46059c0e066e5a82b8ac9c640124..a73da4f255de13b889204eb80e02848a05dab927 100644
(file)
--- a/
updateHostsFile.py
+++ b/
updateHostsFile.py
@@
-1483,9
+1483,9
@@
def get_file_by_url(url):
"""
try:
- f = urlopen(url)
- soup = BeautifulSoup(f.read(), "lxml").get_text()
- return "\n".join(list(map(domain_to_idna, soup.split("\n"))))
+ with urlopen(url) as f:
+
soup = BeautifulSoup(f.read(), "lxml").get_text()
+
return "\n".join(list(map(domain_to_idna, soup.split("\n"))))
except Exception:
print("Problem getting file: ", url)
git clone https://git.99rst.org/PROJECT