Loading bin/lesson_check.py +1 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ import sys import os import glob import json import yaml import re from optparse import OptionParser Loading Loading @@ -131,8 +130,7 @@ def check_config(reporter, source_dir): """Check configuration file.""" config_file = os.path.join(source_dir, '_config.yml') with open(config_file, 'r') as reader: config = yaml.load(reader) config = load_yaml(config_file) reporter.check_field(config_file, 'configuration', config, 'kind', 'lesson') Loading bin/util.py +15 −1 Original line number Diff line number Diff line import sys import json import yaml from subprocess import Popen, PIPE try: import yaml except ImportError: print('Unable to import YAML module: please install PyYAML', file=sys.stderr) sys.exit(1) class Reporter(object): """Collect and report errors.""" Loading Loading @@ -106,3 +110,13 @@ def split_metadata(path, text): sys.exit(1) return metadata_raw, metadata_yaml, text def load_yaml(filename): """ Wrapper around YAML loading so that 'import yaml' and error handling is only needed in one place. """ with open(filename, 'r') as reader: return yaml.load(reader) bin/workshop_check.py +11 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ docstrings on the checking functions for a summary of the checks. import sys import os import re import yaml from datetime import date from util import Reporter, split_metadata Loading Loading @@ -373,13 +372,19 @@ def check_config(reporter, filename): Check YAML configuration file. """ with open(filename, 'r') as reader: config = yaml.load(reader) config = load_yaml(filename) reporter.check(config['kind'] == 'workshop', kind = config.get('kind', None) reporter.check(kind == 'workshop', filename, 'Not configured as a workshop: found "{0}" instead', config['kind']) 'Missing or unknown kind of event: {0}', kind) carpentry = config.get('carpentry', None) reporter.check(carpentry in ('swc', 'dc'), filename, 'Missing or unknown carpentry: {0}', carpentry) def main(): Loading Loading
bin/lesson_check.py +1 −3 Original line number Diff line number Diff line Loading @@ -8,7 +8,6 @@ import sys import os import glob import json import yaml import re from optparse import OptionParser Loading Loading @@ -131,8 +130,7 @@ def check_config(reporter, source_dir): """Check configuration file.""" config_file = os.path.join(source_dir, '_config.yml') with open(config_file, 'r') as reader: config = yaml.load(reader) config = load_yaml(config_file) reporter.check_field(config_file, 'configuration', config, 'kind', 'lesson') Loading
bin/util.py +15 −1 Original line number Diff line number Diff line import sys import json import yaml from subprocess import Popen, PIPE try: import yaml except ImportError: print('Unable to import YAML module: please install PyYAML', file=sys.stderr) sys.exit(1) class Reporter(object): """Collect and report errors.""" Loading Loading @@ -106,3 +110,13 @@ def split_metadata(path, text): sys.exit(1) return metadata_raw, metadata_yaml, text def load_yaml(filename): """ Wrapper around YAML loading so that 'import yaml' and error handling is only needed in one place. """ with open(filename, 'r') as reader: return yaml.load(reader)
bin/workshop_check.py +11 −6 Original line number Diff line number Diff line Loading @@ -7,7 +7,6 @@ docstrings on the checking functions for a summary of the checks. import sys import os import re import yaml from datetime import date from util import Reporter, split_metadata Loading Loading @@ -373,13 +372,19 @@ def check_config(reporter, filename): Check YAML configuration file. """ with open(filename, 'r') as reader: config = yaml.load(reader) config = load_yaml(filename) reporter.check(config['kind'] == 'workshop', kind = config.get('kind', None) reporter.check(kind == 'workshop', filename, 'Not configured as a workshop: found "{0}" instead', config['kind']) 'Missing or unknown kind of event: {0}', kind) carpentry = config.get('carpentry', None) reporter.check(carpentry in ('swc', 'dc'), filename, 'Missing or unknown carpentry: {0}', carpentry) def main(): Loading