the program now checks that all ldraw paths are reachable

Fri, 24 May 2019 14:18:28 +0200

author
Teemu Piippo <teemu@hecknology.net>
date
Fri, 24 May 2019 14:18:28 +0200
changeset 34
7ed2e831acd4
parent 33
d91dfc6056a3
child 35
865cd526e8b6

the program now checks that all ldraw paths are reachable

ldcheck.py file | annotate | diff | comparison | revisions
--- 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