+
+
+def load_yaml(filename):
+ """
+ Wrapper around YAML loading so that 'import yaml' is only needed
+ in one file.
+ """
+
+ try:
+ with open(filename, 'r') as reader:
+ return yaml.load(reader)
+ except (yaml.YAMLError, IOError) as e:
+ print('Unable to load YAML file {0}:\n{1}'.format(
+ filename, e), file=sys.stderr)
+ sys.exit(1)
+
+
+def check_unwanted_files(dir_path, reporter):
+ """
+ Check that unwanted files are not present.
+ """
+
+ for filename in UNWANTED_FILES:
+ path = os.path.join(dir_path, filename)
+ reporter.check(not os.path.exists(path),
+ path,
+ "Unwanted file found")
+
+
+def require(condition, message):
+ """Fail if condition not met."""
+
+ if not condition:
+ print(message, file=sys.stderr)
+ sys.exit(1)