Skip to content

Commit 34ea949

Browse files
committed
Fix incorrect handling of ; within strings + Add new debug features.
1 parent 24335fa commit 34ea949

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

io_scene_halo/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
URL = "https://github.com/General-101/Halo-Asset-Blender-Development-Toolset/issues/new"
22
33

4-
ENABLE_DEBUGGING = False
4+
ENABLE_DEBUG = False
5+
ENABLE_DEBUGGING_PM = False
56
ENABLE_PROFILING = False
6-
77
ENABLE_CRASH_REPORT = True

io_scene_halo/crash_report.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ def dump(self):
3232
def report_crash():
3333
info = sys.exc_info()
3434
traceback.print_exception(info[0], info[1], info[2])
35-
if config.ENABLE_DEBUGGING:
36-
pdb.post_mortem(info[2])
3735
if config.ENABLE_CRASH_REPORT:
3836
report = CrashReport()
3937
report.add_file("crash/traceback.txt", traceback.format_exc())

io_scene_halo/global_functions/global_functions.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import bpy
2929
import sys
3030
import colorsys
31+
import re
3132

3233
from decimal import *
3334
from mathutils import Vector, Quaternion, Matrix
@@ -678,15 +679,23 @@ class SceneParseError(Exception):
678679
class HaloAsset:
679680
"""Helper class for reading in JMS/JMA/ASS files"""
680681

682+
__comment_regex = re.compile("[^\"]*;(?!.*\")")
683+
681684
def __init__(self, filepath):
682685
self._elements = []
683686
self._index = 0
684687
with open(filepath, "r", encoding=test_encoding(filepath)) as file:
685688
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
690699

691700
def left(self):
692701
"""Returns the number of elements left"""
@@ -1139,11 +1148,14 @@ def material_definition_parser(is_import, material_definition_items, default_reg
11391148
return slot_index, lod, permutation, region
11401149

11411150
def run_code(code_string):
1151+
from .. import config
11421152
def toolset_exec(code):
1143-
from .. import config
11441153
if config.ENABLE_PROFILING:
11451154
import cProfile
11461155
cProfile.runctx(code, globals(), caller_locals)
1156+
elif config.ENABLE_DEBUG:
1157+
import pdb
1158+
pdb.runctx(code, globals(), caller_locals)
11471159
else:
11481160
exec(code, globals(), caller_locals)
11491161
import inspect

0 commit comments

Comments
 (0)