Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get annotation checks working, plus some small fixes #57

Merged
merged 9 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 28 additions & 7 deletions makeNoticeList.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#!/usr/bin/env python3

import os
import datetime


noticeList = []

Expand All @@ -10,9 +12,10 @@
and name.endswith('.js') or name.endswith('.ts'):
# print("file", name, os.path.join(root, name))
with open(os.path.join(root, name), 'rt') as sourceFile:
for line in sourceFile:
for n, line in enumerate(sourceFile, start=1):
if 'addNotice' in line and 'function addNotice' not in line \
and 'console.assert' not in line and 'noticeEntry.priority' not in line \
and 'console.log' not in line and 'console.assert' not in line \
and 'noticeEntry' not in line \
and 'grammarCheckResult.error' not in line \
and '...' not in line:
strippedLine = line.strip()
Expand All @@ -22,7 +25,7 @@
cleanedLine = strippedLine.replace('addNoticePartial','') \
.replace('addNotice6to7','') \
.replace('addNotice5','').replace('addNotice6','').replace('addNotice8','').replace('addNotice9','') \
.replace('addNoticeCV8','').replace('addNotice10','') \
.replace('addNoticePartial','').replace('addNotice10','') \
.replace('addNotice','')
if cleanedLine.startswith('('): cleanedLine = cleanedLine[1:]
cleanedLine = cleanedLine.replace('{','').replace('}','')
Expand All @@ -33,10 +36,28 @@
adjustedLine = adjustedLine.strip().replace(' ',' ')
print("adjustedLine", adjustedLine)
if not adjustedLine: halt
noticeList.append(adjustedLine)
noticeList.append(f"{adjustedLine}\tfrom {name} line {n:,}")
# for name in dirs:
# print("dir", name, os.path.join(root, name))

print(f"\nGot {len(noticeList)} notices:")
for notice in sorted(noticeList, reverse=True):
print(f" {notice}")

def makeKey(noticeLine):
# Gives proper sorting of 2-3 digit priority numbers
index = 0
string = ''
while noticeLine[index].isdigit():
string += noticeLine[index]
index += 1
if string: return int(string)
return 99999 # Return a big number for lines not starting with digits


filename = 'noticeList.txt'
with open(filename, 'wt') as outputFile:
print(f"\nGot {len(noticeList)} notices:")
outputFile.write(f"Last updated {datetime.datetime.now()} by makeNoticeList.py\n")
outputFile.write(f"Got {len(noticeList)} notices:\n")
for notice in sorted(noticeList, reverse=True, key=makeKey):
print(f" {notice}")
outputFile.write(f" {notice}\n")
print(f"Wrote {len(noticeList)} sorted notices to {filename}.")
466 changes: 238 additions & 228 deletions noticeList.txt

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "uw-content-validation",
"description": "Functions for Checking Door43.org Scriptural Content/Resources.",
"version": "0.8.15",
"version": "0.8.16_alpha4",
"private": false,
"homepage": "https://unfoldingword.github.io/uw-content-validation/",
"repository": {
Expand Down Expand Up @@ -90,4 +90,4 @@
"<rootDir>/dist/"
]
}
}
}
Loading