tests/subfiles.py

changeset 147
bec55b021ae7
parent 145
fde18c4d6784
equal deleted inserted replaced
146:3555679d276b 147:bec55b021ae7
14 zero. 14 zero.
15 ''' 15 '''
16 yield from ( 16 yield from (
17 report_problem('zero-determinant', bad_object = subfile_reference) 17 report_problem('zero-determinant', bad_object = subfile_reference)
18 for subfile_reference in model.subfile_references 18 for subfile_reference in model.subfile_references
19 if abs(subfile_reference.matrix.determinant() - 0) < 1e-15 19 if abs(subfile_reference.matrix.determinant() - 0) < 1e-5
20 ) 20 )
21 21
22 def scaling_description(scaling, axes = 'xyz'): 22 def scaling_description(scaling, axes = 'xyz'):
23 ''' 23 '''
24 Returns a pretty description of a scaling vector. The axes parameter 24 Returns a pretty description of a scaling vector. The axes parameter
113 str.format('cyclical subfile dependency: {chain}', 113 str.format('cyclical subfile dependency: {chain}',
114 **locals(), 114 **locals(),
115 ), 115 ),
116 ) 116 )
117 @problem_type('bad-subfile', 117 @problem_type('bad-subfile',
118 severity = 'hold', 118 severity = 'warning',
119 message = lambda path, problem_text: 119 message = lambda path, problem_text:
120 str.format('cannot process subfile "{path}": {problem_text}', 120 str.format('cannot process subfile "{path}": {problem_text}',
121 **locals(), 121 **locals(),
122 ), 122 ),
123 ) 123 )
160 Tests subfile references for such qualities that are dependent on the 160 Tests subfile references for such qualities that are dependent on the
161 actual contents of the subfiles. Checks whether moved-to files are used. 161 actual contents of the subfiles. Checks whether moved-to files are used.
162 Checks whether flat subfiles are scaled in the flat direction. 162 Checks whether flat subfiles are scaled in the flat direction.
163 ''' 163 '''
164 import filecache 164 import filecache
165 cache = filecache.SubfileCache(model.ldraw_directories) 165 cache = filecache.SubfileCache(context = model.context)
166 if model.header.valid: 166 if model.header.valid:
167 cache.reference_stack.append(model.header.name) 167 cache.reference_stack.append(model.header.name)
168 failed_subfiles = set() 168 failed_subfiles = set()
169 for subfile_reference, has_invertnext in subfile_references_with_invertnext(model): 169 for subfile_reference, has_invertnext in subfile_references_with_invertnext(model):
170 path = subfile_reference.subfile_path.lower() 170 path = subfile_reference.subfile_path.lower()

mercurial