Skip to content

Commit

Permalink
Fix incorrect handling of ; within strings + Add new debug features.
Browse files Browse the repository at this point in the history
  • Loading branch information
num0005 committed Oct 16, 2021
1 parent 24335fa commit 34ea949
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
4 changes: 2 additions & 2 deletions io_scene_halo/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
URL = "https://github.com/General-101/Halo-Asset-Blender-Development-Toolset/issues/new"
EMAIL = "[email protected]"

ENABLE_DEBUGGING = False
ENABLE_DEBUG = False
ENABLE_DEBUGGING_PM = False
ENABLE_PROFILING = False

ENABLE_CRASH_REPORT = True
2 changes: 0 additions & 2 deletions io_scene_halo/crash_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
22 changes: 17 additions & 5 deletions io_scene_halo/global_functions/global_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import bpy
import sys
import colorsys
import re

from decimal import *
from mathutils import Vector, Quaternion, Matrix
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 34ea949

Please sign in to comment.