[notodiff] Validate the input paths before proceeding
@@ -28,6 +28,7 @@ import argparse
import glob
import logging
import os
+import sys
from nototools import gpos_diff, gsub_diff, shape_diff
@@ -113,6 +114,17 @@ def _run_multiple(func, filematch, dir_a, dir_b, *args):
logger.info('Compared %d fonts' % compared)
+def _validate_paths(before_path, after_path):
+ valid_paths = True
+ if not os.path.exists(before_path):
+ print('Before path is invalid: %s' % before_path)
+ valid_paths = False
+ if not os.path.exists(after_path):
+ print('After path is invalid: %s' % after_path)
+ valid_paths = False
+ return valid_paths
+
+
def main():
parser = argparse.ArgumentParser(
description='Compare fonts.')
@@ -145,6 +157,9 @@ def main():
logging.basicConfig(level=getattr(logging, args.verbose.upper()))
+ if not _validate_paths(args.before, args.after):
+ return 1
+
if args.diff_type in ('area', 'shape', 'area-shape-product', 'rendered'):
stats = {}
if args.match:
@@ -180,4 +195,4 @@ def main():
if __name__ == '__main__':
- main()
+ sys.exit(main())
