report only flag

This commit is contained in:
bMorgan01 2022-09-01 12:05:43 -06:00
parent 79958995d2
commit 653ce94324

17
main.py
View file

@ -8,7 +8,8 @@ from urllib.request import Request, urlopen
from os.path import exists
from shutil import move
import language_tool_python
import argparse
parser = argparse.ArgumentParser()
def spider(prefix, domain, exclude):
return spider_rec(dict(), prefix, domain, "/", exclude)
@ -64,7 +65,8 @@ def abbrev_num(n):
return str(prefix) + abbrev
def main():
def main(report: bool):
if not report:
print("Reading conf...")
conf = []
@ -79,10 +81,12 @@ def main():
ignores = conf[5:conf.index("# Custom Dictionary Ex: Strato")]
custDict = conf[conf.index("# Custom Dictionary Ex: Strato") + 1::]
if not report:
print("Crawling site...")
links = spider(prefix, domain, ignores)
date = datetime.datetime.utcnow()
if not report:
print("Starting local language servers for")
tools = dict()
langs = []
@ -91,9 +95,11 @@ def main():
langs.append(links[l][1])
for lang in langs:
if not report:
print("\t", lang + "...")
tools[lang] = language_tool_python.LanguageTool(lang)
if not report:
print("Spell and grammar checking...")
links_matched = dict()
all_matches = 0
@ -114,6 +120,7 @@ def main():
if len(matches) > 0:
links_matched[l] = matches
if not report:
print()
print("Potential errors:", all_matches, "\t", "Errors ignored:", all_matches - all_filtered_matches, "\t",
"To Fix:", all_filtered_matches)
@ -146,7 +153,11 @@ def main():
print(''.join(['='] * 100), "\n")
if not report:
print("Done.")
main()
parser.add_argument("-r", "--report-only", action='store_true', dest='report', help="Silences status updates")
args = parser.parse_args()
main(args.report)