Skip to content

Commit

Permalink
core: fix _env attribute management for Alt() and corresponding repre…
Browse files Browse the repository at this point in the history
…sentation
  • Loading branch information
p1-bmu committed Oct 22, 2021
1 parent 202deaa commit c1a0427
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions pycrate_core/elt.py
Original file line number Diff line number Diff line change
Expand Up @@ -4263,10 +4263,8 @@ def __init__(self, *args, **kw):
# default alternative
if 'DEFAULT' in kw:
self.DEFAULT = kw['DEFAULT']
#self.DEFAULT.set_env(self.get_env())
elif self.__class__.DEFAULT:
self.DEFAULT = self.__class__.DEFAULT.clone()
#self.DEFAULT.set_env(self.get_env())

if self._SAFE_STAT:
self._chk_hier()
Expand Down Expand Up @@ -4336,8 +4334,7 @@ def get_sel(self):
return None

def get_alt(self):
"""Gets the selected alternative, if sv is not None, forces the
alternative selected
"""Gets the selected alternative
Args:
None
Expand All @@ -4350,14 +4347,15 @@ def get_alt(self):
"""
sv = self.get_sel()
if sv in self._content:
return self._content[sv]
elt = self._content[sv]
elt.set_env(self.get_env())
return elt
elif sv in self._GEN:
elt = self._GEN[sv].clone()
self.insert(sv, elt)
return elt
elif self.DEFAULT is not None:
if self.DEFAULT._env is None:
self.DEFAULT.set_env(self.get_env())
self.DEFAULT.set_env(self.get_env())
return self.DEFAULT
else:
raise(EltErr('{0} [set_val]: invalid selection value {1!r}'\
Expand Down Expand Up @@ -4705,7 +4703,7 @@ def show(self):
desc = ''
#
alts = alt.show()
if alts[:4] == '### ':
if alts.lstrip()[:4] == '### ':
# when the alternative is a constructed element
return alts.replace('### ', '### %s%s%s : %r -> ' % (self._name, desc, trans, sv), 1)
else:
Expand Down

0 comments on commit c1a0427

Please sign in to comment.