diff --git a/io_scene_halo/config.py b/io_scene_halo/config.py index c47cfe9c4..4ca7ea399 100644 --- a/io_scene_halo/config.py +++ b/io_scene_halo/config.py @@ -1,7 +1,7 @@ URL = "https://github.com/General-101/Halo-Asset-Blender-Development-Toolset/issues/new" EMAIL = "halo-asset-toolset@protonmail.com" -ENABLE_DEBUGGING = False +ENABLE_DEBUG = False +ENABLE_DEBUGGING_PM = False ENABLE_PROFILING = False - ENABLE_CRASH_REPORT = True diff --git a/io_scene_halo/crash_report.py b/io_scene_halo/crash_report.py index 74ed04a3f..9a032c5c1 100644 --- a/io_scene_halo/crash_report.py +++ b/io_scene_halo/crash_report.py @@ -32,8 +32,6 @@ def dump(self): def report_crash(): info = sys.exc_info() traceback.print_exception(info[0], info[1], info[2]) - if config.ENABLE_DEBUGGING: - pdb.post_mortem(info[2]) if config.ENABLE_CRASH_REPORT: report = CrashReport() report.add_file("crash/traceback.txt", traceback.format_exc()) diff --git a/io_scene_halo/global_functions/global_functions.py b/io_scene_halo/global_functions/global_functions.py index ba1066cf8..7b04b49fc 100644 --- a/io_scene_halo/global_functions/global_functions.py +++ b/io_scene_halo/global_functions/global_functions.py @@ -28,6 +28,7 @@ import bpy import sys import colorsys +import re from decimal import * from mathutils import Vector, Quaternion, Matrix @@ -678,15 +679,23 @@ class SceneParseError(Exception): class HaloAsset: """Helper class for reading in JMS/JMA/ASS files""" + __comment_regex = re.compile("[^\"]*;(?!.*\")") + def __init__(self, filepath): self._elements = [] self._index = 0 with open(filepath, "r", encoding=test_encoding(filepath)) as file: for line in file: - processed_line = line.split(";", 1)[0].strip() - for element in processed_line.split("\t"): - if element != '': #Sternly written letters will be sent to the person or team who designed the split() function - self._elements.append(element) + for element in line.strip().split("\t"): + if element != '': + comment_match = re.search(self.__comment_regex, element) + if comment_match is None: + self._elements.append(element) + else: + processed_element = element[: comment_match.end() - 1] + if processed_element != '': + self._elements.append(element) + break # ignore the rest of the line if we found a comment def left(self): """Returns the number of elements left""" @@ -1139,11 +1148,14 @@ def material_definition_parser(is_import, material_definition_items, default_reg return slot_index, lod, permutation, region def run_code(code_string): + from .. import config def toolset_exec(code): - from .. import config if config.ENABLE_PROFILING: import cProfile cProfile.runctx(code, globals(), caller_locals) + elif config.ENABLE_DEBUG: + import pdb + pdb.runctx(code, globals(), caller_locals) else: exec(code, globals(), caller_locals) import inspect