Loading bin/lesson_check.py +10 −0 Original line number Diff line number Diff line Loading @@ -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): Loading bin/util.py +8 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ UNWANTED_FILES = [ ] REPORTER_NOT_SET = [] class Reporter(object): """Collect and report errors.""" Loading @@ -26,11 +28,16 @@ class Reporter(object): 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) Loading Loading
bin/lesson_check.py +10 −0 Original line number Diff line number Diff line Loading @@ -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): Loading
bin/util.py +8 −1 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ UNWANTED_FILES = [ ] REPORTER_NOT_SET = [] class Reporter(object): """Collect and report errors.""" Loading @@ -26,11 +28,16 @@ class Reporter(object): 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) Loading