diff --git a/pyproject.toml b/pyproject.toml index ca0041d0..e8f2bcf4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -71,7 +71,7 @@ format-check = [ ] style-check = [ {cmd = "pflake8 --version"}, - {cmd = "pflake8 jrnl tests"}, + {cmd = "pflake8 jrnl tests tasks.py"}, ] sort-run = [ {cmd = "isort ."}, diff --git a/tasks.py b/tasks.py index 30e9635f..453c2334 100644 --- a/tasks.py +++ b/tasks.py @@ -1,29 +1,30 @@ # Copyright © 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html +import json +import os +import pathlib + +import requests +import xmltodict + DOCS_URL = "http://127.0.0.1:8000" SITEMAP_FILENAME = "sitemap.xml" CONFIG_FILENAME = "config.json" -def delete_files(files): - import pathlib +def delete_files(files): for file in files: pathlib.Path(file).unlink(missing_ok=True) def generate_sitemap(): - import requests - sitemap = requests.get(f"{DOCS_URL}/{SITEMAP_FILENAME}") - with open(SITEMAP_FILENAME, 'wb') as f: + with open(SITEMAP_FILENAME, "wb") as f: f.write(sitemap.content) def generate_pa11y_config_from_sitemap(): - import xmltodict - import json - with open(SITEMAP_FILENAME) as f: xml_sitemap = xmltodict.parse(f.read()) @@ -33,13 +34,11 @@ def generate_pa11y_config_from_sitemap(): ] urls += [url["loc"] for url in xml_sitemap["urlset"]["url"]] - with open(CONFIG_FILENAME, 'w') as f: + with open(CONFIG_FILENAME, "w") as f: f.write(json.dumps({"urls": urls})) def output_file(file): - import os - if not os.getenv("CI", False): return @@ -48,5 +47,4 @@ def output_file(file): with open(file) as f: print(f.read()) - print('::endgroup::') - + print("::endgroup::")