Commit cd7768e8 authored by Jim Fulton's avatar Jim Fulton

Changed so exception is raised if a sequence cannot be gotten during

rendering.
parent f62fb973
...@@ -110,10 +110,11 @@ __doc__='''Conditional insertion ...@@ -110,10 +110,11 @@ __doc__='''Conditional insertion
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__rcs_id__='$Id: DT_If.py,v 1.4 1997/09/25 18:56:38 jim Exp $' __rcs_id__='$Id: DT_If.py,v 1.5 1997/11/07 17:08:11 jim Exp $'
__version__='$Revision: 1.4 $'[11:-2] __version__='$Revision: 1.5 $'[11:-2]
from DT_Util import * from DT_Util import *
import sys
class If: class If:
blockContinuations='else','elif' blockContinuations='else','elif'
...@@ -151,7 +152,9 @@ class If: ...@@ -151,7 +152,9 @@ class If:
for name, expr, section in self.sections: for name, expr, section in self.sections:
if expr is None: if expr is None:
try: v=md[name] try: v=md[name]
except: v=None except KeyError, ev:
if ev is not name: raise KeyError, name, sys.exc_traceback
v=None
else: else:
v=expr.eval(md) v=expr.eval(md)
...@@ -175,8 +178,11 @@ class Else: ...@@ -175,8 +178,11 @@ class Else:
self.section=section self.section=section
def render(self,md): def render(self,md):
try: v=md[self.__name__] name=self.__name__
except: v=None try: v=md[name]
except KeyError, ev:
if ev is not name: raise KeyError, name, sys.exc_traceback
v=None
if not v: return self.section(None,md) if not v: return self.section(None,md)
return '' return ''
...@@ -185,6 +191,10 @@ class Else: ...@@ -185,6 +191,10 @@ class Else:
########################################################################## ##########################################################################
# #
# $Log: DT_If.py,v $ # $Log: DT_If.py,v $
# Revision 1.5 1997/11/07 17:08:11 jim
# Changed so exception is raised if a sequence cannot be gotten during
# rendering.
#
# Revision 1.4 1997/09/25 18:56:38 jim # Revision 1.4 1997/09/25 18:56:38 jim
# fixed problem in reporting errors # fixed problem in reporting errors
# #
......
...@@ -228,9 +228,9 @@ ...@@ -228,9 +228,9 @@
Missing values are either 'None' or the attribute 'Value' Missing values are either 'None' or the attribute 'Value'
of the module 'Missing', if present. of the module 'Missing', if present.
''' ''' #'
__rcs_id__='$Id: DT_In.py,v 1.8 1997/10/28 16:33:49 paul Exp $' __rcs_id__='$Id: DT_In.py,v 1.9 1997/11/07 17:08:33 jim Exp $'
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -284,7 +284,7 @@ __rcs_id__='$Id: DT_In.py,v 1.8 1997/10/28 16:33:49 paul Exp $' ...@@ -284,7 +284,7 @@ __rcs_id__='$Id: DT_In.py,v 1.8 1997/10/28 16:33:49 paul Exp $'
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.8 $'[11:-2] __version__='$Revision: 1.9 $'[11:-2]
from DT_Util import * from DT_Util import *
from string import find, atoi, join from string import find, atoi, join
...@@ -332,9 +332,7 @@ class In: ...@@ -332,9 +332,7 @@ class In:
def render(self, md): def render(self, md):
expr=self.expr expr=self.expr
if expr is None: if expr is None: sequence=md[self.__name__]
try: sequence=md[self.__name__] or None
except: sequence=None
else: sequence=expr.eval(md) else: sequence=expr.eval(md)
if not sequence: if not sequence:
...@@ -790,6 +788,10 @@ class sequence_variables: ...@@ -790,6 +788,10 @@ class sequence_variables:
############################################################################ ############################################################################
# $Log: DT_In.py,v $ # $Log: DT_In.py,v $
# Revision 1.9 1997/11/07 17:08:33 jim
# Changed so exception is raised if a sequence cannot be gotten during
# rendering.
#
# Revision 1.8 1997/10/28 16:33:49 paul # Revision 1.8 1997/10/28 16:33:49 paul
# Small change to docstring. # Small change to docstring.
# #
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment