-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into write_to_stream
- Loading branch information
Showing
3 changed files
with
35 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import xml.etree.ElementTree as ET | ||
import urllib.request | ||
|
||
NS = {"a": "http://www.sitemaps.org/schemas/sitemap/0.9"} | ||
TOLERANCE = 0.8 | ||
|
||
|
||
def discover_urls(): | ||
tree = ET.parse("doc/build/html/sitemap.xml") | ||
root = tree.getroot() | ||
return [node.find("a:loc", NS).text for node in root.findall("a:url", NS)] | ||
|
||
|
||
def test_urls(urls): | ||
passed = 0 | ||
for url in urls: | ||
code = 404 | ||
try: | ||
code = urllib.request.urlopen(url).getcode() | ||
except urllib.error.HTTPError as e: | ||
print(url, e) | ||
if code == 200: | ||
passed += 1 | ||
else: | ||
print(url, code) | ||
if passed / len(urls) < TOLERANCE: | ||
raise ValueError(f"Too many URLs failed") | ||
|
||
|
||
if __name__ == "__main__": | ||
test_urls(discover_urls()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters