Tue, 25 Aug 2020 23:04:27 +0300
replaced the collinear test with a new one based on the hairline test that checks interior angles against official limits of 0.025 and 179.9
3
1dc58f44d556
Can now write dat files, added direct color handling
Santeri Piippo
parents:
diff
changeset
|
1 | #!/usr/bin/env python3 |
8 | 2 | from sys import version_info |
3 | if version_info < (3, 4): | |
4 | raise RuntimeError('Python 3.4 or newer required') | |
5 | ||
100
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
6 | appname = 'ldcheck' |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
7 | version = (0, 0, 9999) |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
8 | version_string = str.join('.', map(str, version)) |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
9 | |
8 | 10 | from colours import load_colours |
7 | 11 | from geometry import * |
8 | 12 | from pathlib import Path |
13 | 13 | import linetypes |
47
4da025d0b283
added work on header check
Teemu Piippo <teemu@hecknology.net>
parents:
38
diff
changeset
|
14 | import header |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
15 | import parse |
3
1dc58f44d556
Can now write dat files, added direct color handling
Santeri Piippo
parents:
diff
changeset
|
16 | |
9
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
17 | from os.path import realpath |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
18 | script_directory = Path(realpath(__file__)).parent |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
19 | |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
20 | def load_config(filename): |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
21 | from configobj import ConfigObj |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
22 | from copy import deepcopy |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
23 | config = ConfigObj(filename, encoding = 'UTF8') |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
24 | read_config = deepcopy(config) |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
25 | if 'libraries' not in config: |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
26 | config['libraries'] = ['/path/to/ldraw'] |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
27 | if config != read_config: |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
28 | config.write() |
34
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
29 | check_library_paths(config) |
9
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
30 | return config |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
31 | |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
32 | def library_paths(config): |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
33 | for library_path_string in config['libraries']: |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
34 | yield Path(library_path_string).expanduser() |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
35 | |
34
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
36 | def check_library_paths(config): |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
37 | from sys import exit |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
38 | problems = False |
36
2753aad79678
now checks that paths are specified
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
39 | have_paths = False |
34
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
40 | for library_path in library_paths(config): |
36
2753aad79678
now checks that paths are specified
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
41 | have_paths = True |
34
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
42 | if not library_path.exists(): |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
43 | problems = True |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
44 | print(str.format( |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
45 | 'Library path {} does not exist', |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
46 | library_path, |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
47 | )) |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
48 | elif not library_path.exists(): |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
49 | problems = True |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
50 | print(str.format( |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
51 | 'Library path {} is not a directory', |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
52 | library_path, |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
53 | )) |
36
2753aad79678
now checks that paths are specified
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
54 | if not have_paths: |
2753aad79678
now checks that paths are specified
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
55 | print('No LDraw path specified') |
2753aad79678
now checks that paths are specified
Teemu Piippo <teemu@hecknology.net>
parents:
34
diff
changeset
|
56 | problems = True |
34
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
57 | if problems: |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
58 | print('Please fix ldcheck.cfg') |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
59 | exit(1) |
7ed2e831acd4
the program now checks that all ldraw paths are reachable
Teemu Piippo <teemu@hecknology.net>
parents:
32
diff
changeset
|
60 | |
9
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
61 | def find_ldconfig_ldr_paths(config): |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
62 | for library_path in library_paths(config): |
17 | 63 | yield from [ |
64 | library_path / path | |
65 | for path in ['LDConfig.ldr', 'ldconfig.ldr'] | |
66 | if (library_path / path).is_file() | |
8 | 67 | ] |
68 | ||
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
69 | import argparse |
62
f0a6bf48b05e
Problem reporting revamp, program is now aware of its problem types
Teemu Piippo <teemu@hecknology.net>
parents:
54
diff
changeset
|
70 | |
81
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
71 | class ListProblemsAction(argparse.Action): |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
72 | def __init__(self, option_strings, dest, nargs = None, **kwargs): |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
73 | super().__init__(option_strings, dest, nargs = 0, **kwargs) |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
74 | def __call__(self, *args, **kwargs): |
63
8949af6a4279
added the list of issues onto the web frontend
Teemu Piippo <teemu@hecknology.net>
parents:
62
diff
changeset
|
75 | import testsuite |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
76 | from sys import exit |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
77 | from re import sub |
63
8949af6a4279
added the list of issues onto the web frontend
Teemu Piippo <teemu@hecknology.net>
parents:
62
diff
changeset
|
78 | test_suite = testsuite.load_tests() |
8949af6a4279
added the list of issues onto the web frontend
Teemu Piippo <teemu@hecknology.net>
parents:
62
diff
changeset
|
79 | for warning_type in testsuite.all_problem_types(test_suite): |
62
f0a6bf48b05e
Problem reporting revamp, program is now aware of its problem types
Teemu Piippo <teemu@hecknology.net>
parents:
54
diff
changeset
|
80 | print(str.format('{name}: {severity}: "{message}"', |
f0a6bf48b05e
Problem reporting revamp, program is now aware of its problem types
Teemu Piippo <teemu@hecknology.net>
parents:
54
diff
changeset
|
81 | name = warning_type.name, |
f0a6bf48b05e
Problem reporting revamp, program is now aware of its problem types
Teemu Piippo <teemu@hecknology.net>
parents:
54
diff
changeset
|
82 | severity = warning_type.severity, |
63
8949af6a4279
added the list of issues onto the web frontend
Teemu Piippo <teemu@hecknology.net>
parents:
62
diff
changeset
|
83 | message = warning_type.placeholder_message(), |
62
f0a6bf48b05e
Problem reporting revamp, program is now aware of its problem types
Teemu Piippo <teemu@hecknology.net>
parents:
54
diff
changeset
|
84 | )) |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
85 | exit(0) |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
86 | |
98 | 87 | def format_report(report, model, test_suite, *, use_colors = True): |
88 | from testsuite import problem_text | |
89 | messages = [] | |
90 | for problem in report['problems']: | |
91 | text_colour = '' | |
92 | if use_colors: | |
93 | if problem.severity == 'hold': | |
94 | text_colour = colorama.Fore.LIGHTRED_EX | |
95 | elif problem.severity == 'warning': | |
96 | text_colour = colorama.Fore.LIGHTBLUE_EX | |
97 | ldraw_code = model.body[problem.body_index].textual_representation() | |
98 | message = str.format( | |
99 | '{text_colour}{model_name}:{line_number}: {problem_type}: {message}' | |
100 | '{colour_reset}\n\t{ldraw_code}', | |
101 | text_colour = text_colour, | |
102 | model_name = model.name, | |
103 | line_number = problem.line_number, | |
104 | problem_type = problem.severity, | |
105 | message = problem_text(problem, test_suite), | |
106 | colour_reset = use_colors and colorama.Fore.RESET or '', | |
107 | ldraw_code = ldraw_code, | |
108 | ) | |
109 | messages.append(message) | |
110 | return '\n'.join(messages) | |
111 | ||
3
1dc58f44d556
Can now write dat files, added direct color handling
Santeri Piippo
parents:
diff
changeset
|
112 | if __name__ == '__main__': |
1dc58f44d556
Can now write dat files, added direct color handling
Santeri Piippo
parents:
diff
changeset
|
113 | from sys import argv |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
114 | parser = argparse.ArgumentParser() |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
115 | parser.add_argument('filename') |
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
116 | parser.add_argument('--list', |
81
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
117 | action = ListProblemsAction, |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
118 | help = 'lists all possible problem types and exit', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
119 | ) |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
120 | parser.add_argument('--dump', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
121 | action = 'store_true', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
122 | help = 'dumps the internal parsed structure of the part file', |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
123 | ) |
81
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
124 | parser.add_argument('--rebuild', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
125 | action = 'store_true', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
126 | help = 'parses the part file and prints it back out, used for ' |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
127 | 'testing whether the program interprets part files correctly', |
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
128 | ) |
92
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
129 | parser.add_argument('--subfile', |
81
e65d82501a38
added better help entries to command line parameters
Teemu Piippo <teemu@hecknology.net>
parents:
77
diff
changeset
|
130 | action = 'store_true', |
92
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
131 | help = 'finds a subfile by name and prints out information about it' |
85
4438502fd3e0
fixed the use of moved-to-files check not working if there were non-alphanumerics in the filename
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
132 | ) |
98 | 133 | parser.add_argument('--color', |
134 | action = 'store_true', | |
135 | help = 'use colors' | |
136 | ) | |
100
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
137 | parser.add_argument('-v', '--version', |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
138 | action = 'version', |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
139 | version = str.format('{appname} {version}', |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
140 | appname = appname, |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
141 | version = version_string, |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
142 | ), |
62759e5c4554
add some basic versioning
Teemu Piippo <teemu@hecknology.net>
parents:
98
diff
changeset
|
143 | ) |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
144 | args = parser.parse_args() |
9
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
145 | config = load_config('ldcheck.cfg') |
fea8e9ae6f29
Added matrix code, moved library paths to ldcheck.cfg.
Santeri Piippo
parents:
8
diff
changeset
|
146 | for ldconfig_ldr_path in find_ldconfig_ldr_paths(config): |
8 | 147 | with ldconfig_ldr_path.open() as ldconfig_ldr: |
148 | load_colours(ldconfig_ldr) | |
98 | 149 | if args.color: |
150 | try: | |
151 | import colorama | |
152 | colorama.init() | |
153 | except ImportError: | |
154 | from sys import stderr | |
155 | print('Use of --color requires the colorama module, disabling colours', file = stderr) | |
156 | args.color = False | |
92
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
157 | if args.subfile: |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
158 | import filecache |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
159 | cache = filecache.SubfileCache( |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
160 | ldraw_directories = config['libraries'], |
26
7c263b864371
Added command line option to list all checks.
Santeri Piippo
parents:
21
diff
changeset
|
161 | ) |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
162 | subfile = cache.prepare_file(args.filename) |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
163 | if not subfile.valid: |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
164 | print(subfile.problem) |
92
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
165 | else: |
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
166 | print('Flat dimensions:', repr(subfile.flatness)) |
85
4438502fd3e0
fixed the use of moved-to-files check not working if there were non-alphanumerics in the filename
Teemu Piippo <teemu@hecknology.net>
parents:
81
diff
changeset
|
167 | print('Description:', repr(subfile.description)) |
92
b8d72909d593
improved the mirrored stud check to catch cases where a subfile that contains studs is mirrored
Teemu Piippo <teemu@hecknology.net>
parents:
85
diff
changeset
|
168 | print('Contains studs:', repr(subfile.has_studs)) |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
169 | else: |
94
109fb7cf658f
added a check for non-DOS line endings
Teemu Piippo <teemu@hecknology.net>
parents:
92
diff
changeset
|
170 | with open(args.filename, 'rb') as file: |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
171 | from os.path import basename |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
172 | model = parse.read_ldraw( |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
173 | file, |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
174 | name = basename(args.filename), |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
175 | ldraw_directories = config['libraries']) |
77
d98502ae1f33
improved header extent scanning
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
176 | if args.dump: |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
177 | print('header: ' + type(model.header).__name__) |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
178 | for key in sorted(dir(model.header)): |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
179 | if not key.startswith('__'): |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
180 | print('\t' + key + ': ' + repr(getattr(model.header, key))) |
77
d98502ae1f33
improved header extent scanning
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
181 | for i, entry in enumerate(model.body): |
d98502ae1f33
improved header extent scanning
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
182 | if model.header.valid and i == model.header_size: |
d98502ae1f33
improved header extent scanning
Teemu Piippo <teemu@hecknology.net>
parents:
63
diff
changeset
|
183 | print('--------- End of header') |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
184 | print(entry) |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
185 | elif args.rebuild: |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
186 | for entry in model.body: |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
187 | print(entry.textual_representation(), end = '\r\n') |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
188 | else: |
98 | 189 | from testsuite import load_tests, check_model |
54
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
190 | test_suite = load_tests() |
0c686d10eb49
added tests for moved-to files and scaling in flat dimensions
Teemu Piippo <teemu@hecknology.net>
parents:
47
diff
changeset
|
191 | report = check_model(model, test_suite) |
98 | 192 | print(format_report(report, model, test_suite, use_colors = args.color)) |