|
28 | 28 | import bpy
|
29 | 29 | import sys
|
30 | 30 | import colorsys
|
| 31 | +import re |
31 | 32 |
|
32 | 33 | from decimal import *
|
33 | 34 | from mathutils import Vector, Quaternion, Matrix
|
@@ -678,15 +679,23 @@ class SceneParseError(Exception):
|
678 | 679 | class HaloAsset:
|
679 | 680 | """Helper class for reading in JMS/JMA/ASS files"""
|
680 | 681 |
|
| 682 | + __comment_regex = re.compile("[^\"]*;(?!.*\")") |
| 683 | + |
681 | 684 | def __init__(self, filepath):
|
682 | 685 | self._elements = []
|
683 | 686 | self._index = 0
|
684 | 687 | with open(filepath, "r", encoding=test_encoding(filepath)) as file:
|
685 | 688 | for line in file:
|
686 |
| - processed_line = line.split(";", 1)[0].strip() |
687 |
| - for element in processed_line.split("\t"): |
688 |
| - if element != '': #Sternly written letters will be sent to the person or team who designed the split() function |
689 |
| - self._elements.append(element) |
| 689 | + for element in line.strip().split("\t"): |
| 690 | + if element != '': |
| 691 | + comment_match = re.search(self.__comment_regex, element) |
| 692 | + if comment_match is None: |
| 693 | + self._elements.append(element) |
| 694 | + else: |
| 695 | + processed_element = element[: comment_match.end() - 1] |
| 696 | + if processed_element != '': |
| 697 | + self._elements.append(element) |
| 698 | + break # ignore the rest of the line if we found a comment |
690 | 699 |
|
691 | 700 | def left(self):
|
692 | 701 | """Returns the number of elements left"""
|
@@ -1139,11 +1148,14 @@ def material_definition_parser(is_import, material_definition_items, default_reg
|
1139 | 1148 | return slot_index, lod, permutation, region
|
1140 | 1149 |
|
1141 | 1150 | def run_code(code_string):
|
| 1151 | + from .. import config |
1142 | 1152 | def toolset_exec(code):
|
1143 |
| - from .. import config |
1144 | 1153 | if config.ENABLE_PROFILING:
|
1145 | 1154 | import cProfile
|
1146 | 1155 | cProfile.runctx(code, globals(), caller_locals)
|
| 1156 | + elif config.ENABLE_DEBUG: |
| 1157 | + import pdb |
| 1158 | + pdb.runctx(code, globals(), caller_locals) |
1147 | 1159 | else:
|
1148 | 1160 | exec(code, globals(), caller_locals)
|
1149 | 1161 | import inspect
|
|
0 commit comments