Skip to content

Commit

Permalink
Checking that episodes are numbered consecutively
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Wilson committed Jun 22, 2016
1 parent 2a53ed7 commit 3c28d16
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions bin/lesson_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,17 +166,22 @@ def check_fileset(source_dir, reporter, filenames_present):
else:
reporter.add(None, 'Episode {0} has badly-formatted filename', filename)

# Check episode filename numbering.
# Check for duplicate episode numbers.
reporter.check(len(seen) == len(set(seen)),
None,
'Duplicate episode numbers {0} vs {1}',
sorted(seen), sorted(set(seen)))

# Check that numbers are consecutive.
seen = [int(s) for s in seen]
seen.sort()
reporter.check(all([i+1 == n for (i, n) in enumerate(seen)]),
None,
'Missing or non-consecutive episode numbers {0}',
seen)
clean = True
for i in range(len(seen) - 1):
clean = clean and ((seen[i+1] - seen[i]) == 1)
reporter.check(clean,
None,
'Missing or non-consecutive episode numbers {0}',
seen)


def create_checker(args, filename, info):
Expand Down

0 comments on commit 3c28d16

Please sign in to comment.