Skip to content

Commit

Permalink
Improve error message for duplicates as well as missing front matter
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Büchse <[email protected]>
  • Loading branch information
mbuechse committed Dec 21, 2023
1 parent a1fd820 commit e589b4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Tests/chk_adrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,16 @@ def check_names(self, mds):
"""Check the list `mds` of md file names for name collisions"""
# count the occurrences of the prefixes of length 12, e.g., scs-0001-v1-
# no duplicates allowed
codes = collections.Counter([fn[:12] for fn in mds])
duplicates = [item for item in codes.items() if item[1] > 1]
counts = collections.Counter([fn[:12] for fn in mds])
duplicates = sorted([fn for fn in mds if counts[fn[:12]] > 1])
if duplicates:
self.emit(f"duplicates found: {duplicates}")
self.emit(f"duplicates found: {', '.join(duplicates)}")

def check_front_matter(self, fn, front):
"""Check the dict `front` of front matter; `fn` is for context in error messages"""
if front is None:
self.emit(f"in {fn}: is missing front matter altogether")
return
# check each field in isolation
errors = [
key
Expand Down

0 comments on commit e589b4c

Please sign in to comment.