in utils/sitemap.py [0:0]
def generate_sitemap(html_dir: str, sitemap_filename: str = DEF_SITEMAP_FILENAME, *, web_root: str = DEF_WEB_ROOT):
xml_doc = minidom.Document()
urlset = xml_doc.createElement("urlset")
urlset.setAttribute('xmlns', "http://www.sitemaps.org/schemas/sitemap/0.9")
xml_doc.appendChild(urlset)
for html_filename in sorted(_get_all_html_filenames(html_dir)):
sitemap_url = SitemapURL(html_filename, web_root)
for transformation in transformations:
sitemap_url = sitemap_url.apply(transformation)
sitemap_url.append_to_xml(xml_doc, urlset)
with open(sitemap_filename, "wb") as f:
f.write(xml_doc.toprettyxml(indent=" ", encoding='utf-8'))