Start using WmlIterator more systematically.

This commit is contained in:
Eric S. Raymond 2008-11-06 23:28:24 +00:00
parent 06f72fdf4d
commit 7800a69318

View file

@ -333,15 +333,25 @@ declared_spellings = {"GLOBAL":["I'm", "I've", "I'd", "I'll",
"princeling", "wilderlands", "ensorcels"
]}
def printError(nav, *misc):
"""Emit an error locator compatible with Emacs compilation mode."""
if nav.lineno == -1:
print >>sys.stderr, '"%s":' % nav.fname
else:
print >>sys.stderr, '"%s", line %d:' % (nav.fname, nav.lineno+1)
for item in misc:
print >>sys.stderr, item,
print >>sys.stderr #terminate line
def sanity_check(filename, lines):
"Perform sanity and consistency checks on input lines."
for i in range(len(lines)):
for nav in WmlIterator(filename=fn, onerr=printError):
# Check for things marked translated that aren't strings
if "_" in lines[i] and not "wmllint: ignore" in lines[i]:
m = re.search(r'[=(]\s*_\s+("?)', lines[i])
if "_" in nav.text and not "wmllint: ignore" in nav.text:
m = re.search(r'[=(]\s*_\s+("?)', nav.text)
if m and not m.group(1):
msg = '"%s", line %d: translatability mark before non-string' % \
(filename, i+1)
(nav.fname, nav.lineno+1)
print msg
# Sanity-check abilities and traits against notes macros.
# Note: This check is disabled on units derived via [base_unit].
@ -1187,16 +1197,6 @@ def spellcheck(fn, d):
# print "%s: inherited local spellings: %s" % (fn, local_spellings)
map(d.add_to_session, local_spellings)
def printError(nav, *misc):
"""Emit an error locator compatible with Emacs compilation mode."""
if nav.lineno == -1:
print >>sys.stderr, '"%s":' % nav.fname
else:
print >>sys.stderr, '"%s", line %d:' % (nav.fname, nav.lineno+1)
for item in misc:
print >>sys.stderr, item,
print >>sys.stderr #terminate line
# Process this individual file
for nav in WmlIterator(filename=fn, onerr=printError):
#print "element=%s, text=%s" % (nav.element, `nav.text`)