Skip to content

Commit

Permalink
Handle strings from ReqHeroSkill
Browse files Browse the repository at this point in the history
  • Loading branch information
bicobus committed Jan 28, 2024
1 parent 7e12340 commit 95c1302
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/pycestorieseditor/ceevents.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,11 @@ def get_skill_value(ceevent, skill):

def get_skill_text_value(element):
if isinstance(element, SkillsRequired):
return (skill.id for skill in element.skill_required)
return [skill.id for skill in element.skill_required]
if isinstance(element, SkillsToLevel):
return (skill.id for skill in element.skill)
return [skill.id for skill in element.skill]
if isinstance(element, str):
return [element]
raise Exception("element of type '%s' not handled" % type(element))


Expand All @@ -175,7 +177,7 @@ def filter_and_yield_skills(members, ceevent, cname):
lambda x: x is not None,
(get_skill_value(ceevent, skillname) for skillname in SKILLNAMES),
):
yield (x for x in get_skill_text_value(value)), cname
yield get_skill_text_value(value), cname


def filter_and_yield_from_options(members, ceevent, cname):
Expand All @@ -192,9 +194,9 @@ def filter_and_yield_from_options(members, ceevent, cname):
):
if otree == "menu_options":
for skill in value:
yield (x for x in get_skill_text_value(skill)), cname
yield get_skill_text_value(skill), cname
else:
yield (x for x in get_skill_text_value(value)), cname
yield get_skill_text_value(value), cname


def filter_ceevent(ceevent: Ceevent, ceeventname):
Expand Down
12 changes: 11 additions & 1 deletion src/pycestorieseditor/wxui.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# © 2024 bicobus <[email protected]>
from __future__ import annotations

import logging
import os
import re
from collections import namedtuple
Expand Down Expand Up @@ -56,6 +57,7 @@
wxicon,
)

logger = logging.getLogger(__name__)
style = get_style_by_name("default")

if wx.Platform == '__WXMSW__':
Expand Down Expand Up @@ -1372,6 +1374,10 @@ def __init__(self, parent, data, *args, **kwargs):


# - Main Window ---
class ModuleProcessingError(Exception):
...


class Legend(wx.BoxSizer):
def __init__(self, parent, text, color, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down Expand Up @@ -1597,7 +1603,11 @@ def pulse(m=None):
init_xsdfile(conf.Read("CE_XSDFILE"))
pulse("Big Bad XML...")
init_bigbadxml()
process_module(xmlfiles, pulse)
try:
process_module(xmlfiles, pulse)
except Exception as e:
logger.error(e)
raise ModuleProcessingError from e
dialog.Close()

def on_reset_event(self, event):
Expand Down

0 comments on commit 95c1302

Please sign in to comment.