fixed the cyclical dependency handling

Mon, 24 Jun 2019 19:21:49 +0300

author
Teemu Piippo <teemu@hecknology.net>
date
Mon, 24 Jun 2019 19:21:49 +0300
changeset 95
a3536e51f6bc
parent 94
109fb7cf658f
child 96
70f8049623ec
child 146
3555679d276b

fixed the cyclical dependency handling

filecache.py file | annotate | diff | comparison | revisions
tests/subfiles.py file | annotate | diff | comparison | revisions
--- a/filecache.py	Mon Jun 24 19:08:24 2019 +0300
+++ b/filecache.py	Mon Jun 24 19:21:49 2019 +0300
@@ -105,7 +105,7 @@
                 subfile.valid = False
                 subfile.problem = 'Description not found'
             if subfile.valid:
-                subfile.vertices = set(parse.model_vertices(model))
+                subfile.vertices = set(parse.model_vertices(model, file_cache = self))
                 subfile.flatness = {'x', 'y', 'z'}
                 for vertex in subfile.vertices:
                     # Use list(subfile.flatness) for iteration because the
--- a/tests/subfiles.py	Mon Jun 24 19:08:24 2019 +0300
+++ b/tests/subfiles.py	Mon Jun 24 19:21:49 2019 +0300
@@ -163,6 +163,8 @@
     '''
     import filecache
     cache = filecache.SubfileCache(model.ldraw_directories)
+    if model.header.valid:
+        cache.reference_stack.append(model.header.name)
     failed_subfiles = set()
     for subfile_reference, has_invertnext in subfile_references_with_invertnext(model):
         path = subfile_reference.subfile_path.lower()
@@ -173,13 +175,14 @@
             try:
                 subfile = cache.prepare_file(path)
             except filecache.CyclicalReferenceError as e:
+                subfile = None
                 failed_subfiles.add(path)
                 yield report_problem(
                     'cyclical-reference',
                     bad_object = subfile_reference,
                     chain = str(e),
                 )
-            if not subfile.valid:
+            if subfile and not subfile.valid:
                 yield report_problem(
                     'bad-subfile',
                     bad_object = subfile_reference,
@@ -187,7 +190,7 @@
                     problem_text = subfile.problem,
                 )
                 failed_subfiles.add(path)
-            else:
+            elif subfile:
                 # Test for use of moved-to files
                 import re
                 match = re.search(r'^\~Moved(?: to (.+))?$', subfile.description)

mercurial