filecache.py

changeset 92
b8d72909d593
parent 58
86014c443635
child 94
109fb7cf658f
--- a/filecache.py	Mon Jun 24 11:48:52 2019 +0300
+++ b/filecache.py	Mon Jun 24 17:31:47 2019 +0300
@@ -25,6 +25,9 @@
         filename,
     ))
 
+def is_logo_stud_name(name):
+    return name in ['stud.dat', 'stud3.dat']
+
 class CyclicalReferenceError(Exception):
     pass
 
@@ -35,6 +38,7 @@
             self.flatness = None
             self.description = None
             self.problem = None
+            self.has_studs = None # Whether or not it contains studs
             self.vertices = set()
     def __init__(self, ldraw_directories):
         '''
@@ -117,8 +121,13 @@
                         break
                 for subfile_reference in model.subfile_references:
                     # Go through all the subfile references so that we catch any
-                    # cyclical references
+                    # cyclical references and to get studs
                     self.prepare_file(subfile_reference.subfile_path)
+                subfile.has_studs = any(
+                    self.cache[subfile_reference.subfile_path].has_studs
+                    or is_logo_stud_name(subfile_reference.subfile_path)
+                    for subfile_reference in model.subfile_references
+                )
         self.reference_stack.pop()
 
 if __name__ == '__main__':

mercurial