parse.py

changeset 145
fde18c4d6784
parent 127
97de6058109e
--- a/parse.py	Fri Sep 18 21:57:36 2020 +0300
+++ b/parse.py	Fri Sep 18 23:51:45 2020 +0300
@@ -9,13 +9,13 @@
 
 class Model:
     def __init__(
-        self, header, body, *, ldraw_directories, \
+        self, header, body, *, context, \
         header_size = 0, line_ending_errors = None
     ):
         self.header = header
         self.body = body
         self.header_size = header_size
-        self.ldraw_directories = ldraw_directories
+        self.context = context # contains stuff like library paths
         self.line_ending_errors = line_ending_errors
     def filter_by_type(self, type):
         yield from [
@@ -58,7 +58,7 @@
         transformation_matrix = complete_matrix(Matrix3x3(), Vertex(0, 0, 0))
     if file_cache is None:
         import filecache
-        file_cache = filecache.SubfileCache(model.ldraw_directories)
+        file_cache = filecache.SubfileCache(ldraw_directories = model.context.libraries)
     for element in model.body:
         if isinstance(element, linetypes.BasePolygon):
             for point in element.geometry.vertices:
@@ -73,7 +73,7 @@
                 point @= matrix_4x4
                 yield point @ transformation_matrix
 
-def read_ldraw(file, *, ldraw_directories, name = ''):
+def read_ldraw(file, *, context, name = ''):
     line_ending_errors = {
         'count': 0,
         'first-at': None,
@@ -100,7 +100,7 @@
         header = header_object,
         body = model_body,
         header_size = end,
-        ldraw_directories = ldraw_directories,
+        context = context,
         line_ending_errors = line_ending_errors,
     )
     model.name = name

mercurial