report only flag
This commit is contained in:
parent
79958995d2
commit
653ce94324
1 changed files with 21 additions and 10 deletions
17
main.py
17
main.py
|
|
@ -8,7 +8,8 @@ from urllib.request import Request, urlopen
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from shutil import move
|
from shutil import move
|
||||||
import language_tool_python
|
import language_tool_python
|
||||||
|
import argparse
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
|
||||||
def spider(prefix, domain, exclude):
|
def spider(prefix, domain, exclude):
|
||||||
return spider_rec(dict(), prefix, domain, "/", exclude)
|
return spider_rec(dict(), prefix, domain, "/", exclude)
|
||||||
|
|
@ -64,7 +65,8 @@ def abbrev_num(n):
|
||||||
return str(prefix) + abbrev
|
return str(prefix) + abbrev
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(report: bool):
|
||||||
|
if not report:
|
||||||
print("Reading conf...")
|
print("Reading conf...")
|
||||||
|
|
||||||
conf = []
|
conf = []
|
||||||
|
|
@ -79,10 +81,12 @@ def main():
|
||||||
ignores = conf[5:conf.index("# Custom Dictionary Ex: Strato")]
|
ignores = conf[5:conf.index("# Custom Dictionary Ex: Strato")]
|
||||||
custDict = conf[conf.index("# Custom Dictionary Ex: Strato") + 1::]
|
custDict = conf[conf.index("# Custom Dictionary Ex: Strato") + 1::]
|
||||||
|
|
||||||
|
if not report:
|
||||||
print("Crawling site...")
|
print("Crawling site...")
|
||||||
links = spider(prefix, domain, ignores)
|
links = spider(prefix, domain, ignores)
|
||||||
date = datetime.datetime.utcnow()
|
date = datetime.datetime.utcnow()
|
||||||
|
|
||||||
|
if not report:
|
||||||
print("Starting local language servers for")
|
print("Starting local language servers for")
|
||||||
tools = dict()
|
tools = dict()
|
||||||
langs = []
|
langs = []
|
||||||
|
|
@ -91,9 +95,11 @@ def main():
|
||||||
langs.append(links[l][1])
|
langs.append(links[l][1])
|
||||||
|
|
||||||
for lang in langs:
|
for lang in langs:
|
||||||
|
if not report:
|
||||||
print("\t", lang + "...")
|
print("\t", lang + "...")
|
||||||
tools[lang] = language_tool_python.LanguageTool(lang)
|
tools[lang] = language_tool_python.LanguageTool(lang)
|
||||||
|
|
||||||
|
if not report:
|
||||||
print("Spell and grammar checking...")
|
print("Spell and grammar checking...")
|
||||||
links_matched = dict()
|
links_matched = dict()
|
||||||
all_matches = 0
|
all_matches = 0
|
||||||
|
|
@ -114,6 +120,7 @@ def main():
|
||||||
if len(matches) > 0:
|
if len(matches) > 0:
|
||||||
links_matched[l] = matches
|
links_matched[l] = matches
|
||||||
|
|
||||||
|
if not report:
|
||||||
print()
|
print()
|
||||||
print("Potential errors:", all_matches, "\t", "Errors ignored:", all_matches - all_filtered_matches, "\t",
|
print("Potential errors:", all_matches, "\t", "Errors ignored:", all_matches - all_filtered_matches, "\t",
|
||||||
"To Fix:", all_filtered_matches)
|
"To Fix:", all_filtered_matches)
|
||||||
|
|
@ -146,7 +153,11 @@ def main():
|
||||||
|
|
||||||
print(''.join(['='] * 100), "\n")
|
print(''.join(['='] * 100), "\n")
|
||||||
|
|
||||||
|
if not report:
|
||||||
print("Done.")
|
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)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue