diff --git a/bin/lesson_check.py b/bin/lesson_check.py index 9e051bd..016b395 100755 --- a/bin/lesson_check.py +++ b/bin/lesson_check.py @@ -146,6 +146,16 @@ def check_config(reporter, source_dir): config_file = os.path.join(source_dir, '_config.yml') config = load_yaml(config_file) reporter.check_field(config_file, 'configuration', config, 'kind', 'lesson') + reporter.check_field(config_file, 'configuration', config, 'carpentry', ('swc', 'dc')) + reporter.check_field(config_file, 'configuration', config, 'title') + reporter.check_field(config_file, 'configuration', config, 'email') + reporter.check_field(config_file, 'configuration', config, 'repo') + reporter.check_field(config_file, 'configuration', config, 'root') + if ('repo' in config) and ('root' in config): + reporter.check(config['repo'].endswith(config['root']), + config_file, + 'Repository name "{0}" not consistent with root "{1}"', + config['repo'], config['root']) def read_all_markdown(source_dir, parser): diff --git a/bin/util.py b/bin/util.py index 8ce17fe..2341bdb 100644 --- a/bin/util.py +++ b/bin/util.py @@ -16,6 +16,8 @@ ] +REPORTER_NOT_SET = [] + class Reporter(object): """Collect and report errors.""" @@ -26,11 +28,16 @@ def __init__(self): self.messages = [] - def check_field(self, filename, name, values, key, expected): + def check_field(self, filename, name, values, key, expected=REPORTER_NOT_SET): """Check that a dictionary has an expected value.""" if key not in values: self.add(filename, '{0} does not contain {1}', name, key) + elif expected is REPORTER_NOT_SET: + pass + elif type(expected) in (tuple, set, list): + if values[key] not in expected: + self.add(filename, '{0} {1} value {2} is not in {3}', name, key, values[key], expected) elif values[key] != expected: self.add(filename, '{0} {1} is {2} not {3}', name, key, values[key], expected)