implement keyword 'unwho ALL' for clearing all "wmllint: who" entries at end of campaign
I realized that as it stood, my dictionary would linger, bad if wmllint were being run on multiple campaigns. A special unwho keyword, 'all', clears the dictionary.
This commit is contained in:
parent
faee03bbf0
commit
c3863ac222
1 changed files with 15 additions and 9 deletions
|
@ -86,9 +86,12 @@
|
|||
# person's entry with a double-minus will cause that character to be removed,
|
||||
# e.g., "-- Garak".
|
||||
#
|
||||
# If a macro is not used in any subsequent scenarios, you can tell wmllint to
|
||||
# stop checking for it with "wmllint: unwho <macro>", where <macro> should be
|
||||
# the string you originally used for "wmllint: who".
|
||||
# At the end of the campaign, *make sure* you use:
|
||||
# wmllint: unwho ALL
|
||||
# This will clear the list of "who" magic comments and tell wmllint to stop
|
||||
# checking for them in later files and directories. If a specific macro is
|
||||
# not used in subsequent scenarios, put "unwho <macro>" in its last scenario,
|
||||
# where <macro> should be the string you originally used for "wmllint: who".
|
||||
#
|
||||
# Similarly, it is possible to explicitly declare a unit's usage class
|
||||
# with a magic comment that looks like this:
|
||||
|
@ -1338,13 +1341,16 @@ def global_sanity_check(filename, lines):
|
|||
whopairs.update({mac: fields[1].strip()})
|
||||
except IndexError:
|
||||
pass
|
||||
if 'wmllint: unwho ' in lines[i]:
|
||||
elif 'wmllint: unwho ' in lines[i]:
|
||||
unmac = lines[i].split("wmllint: unwho ", 1)[1].strip()
|
||||
try:
|
||||
del whopairs[string_strip(unmac)]
|
||||
except KeyError:
|
||||
print >>sys.stderr, '%s, line %s: magic comment "unwho %s" does not match any current keys: %s' \
|
||||
% (filename, i+1, unmac, str(whopairs.keys())[1:-1])
|
||||
if string_strip(unmac).upper() == 'ALL':
|
||||
whopairs.clear()
|
||||
else:
|
||||
try:
|
||||
del whopairs[string_strip(unmac)]
|
||||
except KeyError:
|
||||
print >>sys.stderr, '%s, line %s: magic comment "unwho %s" does not match any current keys: %s' \
|
||||
% (filename, i+1, unmac, str(whopairs.keys())[1:-1])
|
||||
if lines[i].lstrip().startswith('{'):
|
||||
# Recognize macro pairings from "wmllint: who" magic
|
||||
# comments.
|
||||
|
|
Loading…
Add table
Reference in a new issue