ldverify.py

changeset 9
fea8e9ae6f29
parent 8
303c51137cb2
child 10
ccc33237949e
--- a/ldverify.py	Thu Dec 21 12:27:16 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-#!/usr/bin/env python3
-from sys import version_info
-if version_info < (3, 4):
-    raise RuntimeError('Python 3.4 or newer required')
-
-from parse import parse_ldraw_code
-from colours import load_colours
-from geometry import *
-from pathlib import Path
-
-def read_ldraw(file, *, libraries):
-    result = list()
-    for line in file:
-        result.append(parse_ldraw_code(line))
-    return result
-
-def find_ldconfig_ldr_paths(libraries):
-    for library in libraries:
-        ldconfig_paths = [
-            library['path'] / 'LDConfig.ldr',
-            library['path'] / 'ldconfig.ldr',
-        ]
-        for path in ldconfig_paths:
-            if path.is_file():
-                yield path
-
-def hairline_score(smallest_angle):
-    from math import log10
-    return max(0, -log10(smallest_angle))
-
-if __name__ == '__main__':
-    from sys import argv
-    libraries = [{'path': Path('~/ldraw').expanduser(), 'role': 'official'}]
-    for ldconfig_ldr_path in find_ldconfig_ldr_paths(libraries):
-        with ldconfig_ldr_path.open() as ldconfig_ldr:
-            load_colours(ldconfig_ldr)
-    with open(argv[1], 'r') as file:
-        model = read_ldraw(file, libraries = libraries)
-        for line_number, entry in enumerate(model, 1):
-            if hasattr(entry, 'colour'):
-                print(repr(entry.colour))
-            if hasattr(entry, 'geometry') and len(entry.geometry) >= 3:
-                if hairline_score(entry.geometry.smallest_angle) >= 2.0:
-                    print(str.format(
-                        'Hairline {type} at line {line_number}',
-                        type = entry.typename(),
-                        line_number = line_number,
-                    ))
-                    print(entry.textual_representation())
-                    print('-' * 25)
\ No newline at end of file

mercurial