ldcheck.py

changeset 34
7ed2e831acd4
parent 32
75f44d3063da
child 36
2753aad79678
--- a/ldcheck.py	Wed Jan 31 14:36:36 2018 +0200
+++ b/ldcheck.py	Fri May 24 14:18:28 2019 +0200
@@ -21,6 +21,7 @@
         config['libraries'] = ['/path/to/ldraw']
     if config != read_config:
         config.write()
+    check_library_paths(config)
     return config
 
 def read_ldraw(file, *, name = '', config):
@@ -36,6 +37,26 @@
     for library_path_string in config['libraries']:
         yield Path(library_path_string).expanduser()
 
+def check_library_paths(config):
+    from sys import exit
+    problems = False
+    for library_path in library_paths(config):
+        if not library_path.exists():
+            problems = True
+            print(str.format(
+                'Library path {} does not exist',
+                library_path,
+            ))
+        elif not library_path.exists():
+            problems = True
+            print(str.format(
+                'Library path {} is not a directory',
+                library_path,
+            ))
+    if problems:
+        print('Please fix ldcheck.cfg')
+        exit(1)
+
 def find_ldconfig_ldr_paths(config):
     for library_path in library_paths(config):
         yield from [

mercurial