Commit 7997adf2 authored by Jim Fulton's avatar Jim Fulton

fixed problem in reporting errors

parent 7dc06699
"""HTML formated DocumentTemplates """HTML formated DocumentTemplates
$Id: DT_HTML.py,v 1.3 1997/09/22 14:42:08 jim Exp $""" $Id: DT_HTML.py,v 1.4 1997/09/25 18:56:37 jim Exp $"""
from DT_String import String, FileMixin from DT_String import String, FileMixin
import DT_Doc, DT_String, regex import DT_Doc, DT_String, regex
...@@ -38,7 +38,7 @@ class HTML(DT_String.String): ...@@ -38,7 +38,7 @@ class HTML(DT_String.String):
args=strip(args) args=strip(args)
if end: if end:
if not command or name != command.name: if not command or name != command.name:
raise ParseError, 'unexpected end tag' raise ParseError, ('unexpected end tag', tag)
return tag, args, None, None return tag, args, None, None
if command and name in command.blockContinuations: if command and name in command.blockContinuations:
...@@ -178,6 +178,9 @@ class HTMLFile(FileMixin, HTML): ...@@ -178,6 +178,9 @@ class HTMLFile(FileMixin, HTML):
########################################################################## ##########################################################################
# #
# $Log: DT_HTML.py,v $ # $Log: DT_HTML.py,v $
# Revision 1.4 1997/09/25 18:56:37 jim
# fixed problem in reporting errors
#
# Revision 1.3 1997/09/22 14:42:08 jim # Revision 1.3 1997/09/22 14:42:08 jim
# *** empty log message *** # *** empty log message ***
# #
......
...@@ -110,8 +110,8 @@ __doc__='''Conditional insertion ...@@ -110,8 +110,8 @@ __doc__='''Conditional insertion
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__rcs_id__='$Id: DT_If.py,v 1.3 1997/09/22 14:42:49 jim Exp $' __rcs_id__='$Id: DT_If.py,v 1.4 1997/09/25 18:56:38 jim Exp $'
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
from DT_Util import * from DT_Util import *
...@@ -136,12 +136,13 @@ class If: ...@@ -136,12 +136,13 @@ class If:
if args: if args:
ename,expr=name_param(args,'else',1) ename,expr=name_param(args,'else',1)
if ename != name: if ename != name:
raise ParseError, 'name in else does not match if' raise ParseError, ('name in else does not match if', 'in')
self.elses=section self.elses=section
for tname, args, section in blocks[1:]: for tname, args, section in blocks[1:]:
if tname=='else': if tname=='else':
raise ParseError, 'more than one else tag for a single if tag' raise ParseError, (
'more than one else tag for a single if tag', 'in')
args=parse_params(args, name='', expr='') args=parse_params(args, name='', expr='')
name,expr=name_param(args,'elif',1) name,expr=name_param(args,'elif',1)
self.sections.append((name, expr, section)) self.sections.append((name, expr, section))
...@@ -184,6 +185,9 @@ class Else: ...@@ -184,6 +185,9 @@ class Else:
########################################################################## ##########################################################################
# #
# $Log: DT_If.py,v $ # $Log: DT_If.py,v $
# Revision 1.4 1997/09/25 18:56:38 jim
# fixed problem in reporting errors
#
# Revision 1.3 1997/09/22 14:42:49 jim # Revision 1.3 1997/09/22 14:42:49 jim
# added expr # added expr
# #
......
...@@ -212,7 +212,7 @@ ...@@ -212,7 +212,7 @@
of the module 'Missing', if present. of the module 'Missing', if present.
''' '''
__rcs_id__='$Id: DT_In.py,v 1.3 1997/09/22 14:42:50 jim Exp $' __rcs_id__='$Id: DT_In.py,v 1.4 1997/09/25 18:56:38 jim Exp $'
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -266,7 +266,7 @@ __rcs_id__='$Id: DT_In.py,v 1.3 1997/09/22 14:42:50 jim Exp $' ...@@ -266,7 +266,7 @@ __rcs_id__='$Id: DT_In.py,v 1.3 1997/09/22 14:42:50 jim Exp $'
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
from DT_Util import * from DT_Util import *
...@@ -286,13 +286,15 @@ class In: ...@@ -286,13 +286,15 @@ class In:
self.__name__, expr = name, expr self.__name__, expr = name, expr
self.section=section self.section=section
if len(blocks) > 1: if len(blocks) > 1:
if len(blocks) != 2: raise ParseError, 'too many else blocks' if len(blocks) != 2: raise ParseError, (
'too many else blocks', 'in')
tname, args, section = blocks[1] tname, args, section = blocks[1]
args=parse_params(args, name='') args=parse_params(args, name='')
if args: if args:
ename=name_param(args) ename=name_param(args)
if ename != name: if ename != name:
raise ParseError, 'name in else does not match in' raise ParseError, (
'name in else does not match in', 'in')
self.elses=section self.elses=section
...@@ -718,6 +720,9 @@ class sequence_variables: ...@@ -718,6 +720,9 @@ class sequence_variables:
############################################################################ ############################################################################
# $Log: DT_In.py,v $ # $Log: DT_In.py,v $
# Revision 1.4 1997/09/25 18:56:38 jim
# fixed problem in reporting errors
#
# Revision 1.3 1997/09/22 14:42:50 jim # Revision 1.3 1997/09/22 14:42:50 jim
# added expr # added expr
# #
......
'''$Id: DT_Util.py,v 1.3 1997/09/22 14:42:50 jim Exp $''' '''$Id: DT_Util.py,v 1.4 1997/09/25 18:56:39 jim Exp $'''
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.3 $'[11:-2] __version__='$Revision: 1.4 $'[11:-2]
import sys, regex, string, types, math, os import sys, regex, string, types, math, os
from string import rfind, strip, joinfields, atoi,lower,upper,capitalize from string import rfind, strip, joinfields, atoi,lower,upper,capitalize
...@@ -101,10 +101,11 @@ def name_param(params,tag='',expr=0): ...@@ -101,10 +101,11 @@ def name_param(params,tag='',expr=0):
expr=VSEval.Eval(name, __mul__=VSEval.careful_mul, __getattr__=None) expr=VSEval.Eval(name, __mul__=VSEval.careful_mul, __getattr__=None)
return name, expr return name, expr
raise ParseError, 'No name given' raise ParseError, ('No name given', tag)
def parse_params(text, def parse_params(text,
result=None, result=None,
tag='',
unparmre=regex.compile( unparmre=regex.compile(
'\([\0- ]*\([^\0- =\"]+\)\)'), '\([\0- ]*\([^\0- =\"]+\)\)'),
parmre=regex.compile( parmre=regex.compile(
...@@ -150,8 +151,8 @@ def parse_params(text, ...@@ -150,8 +151,8 @@ def parse_params(text,
if result.has_key(''): if result.has_key(''):
if parms.has_key(name): result[name]=parms[name] if parms.has_key(name): result[name]=parms[name]
else: raise ParseError, ( else: raise ParseError, (
'Invalid parameter name, %s <!--%s--> <!--u-->' ('Invalid parameter name, %s <!--%s--> <!--u-->'
% (name, text)) % (name, text)), tag)
else: else:
result['']=name result['']=name
return apply(parse_params,(text[l:],result),parms) return apply(parse_params,(text[l:],result),parms)
...@@ -160,7 +161,8 @@ def parse_params(text, ...@@ -160,7 +161,8 @@ def parse_params(text,
raise InvalidParameter, text raise InvalidParameter, text
if not parms.has_key(name): if not parms.has_key(name):
raise ParseError, 'Invalid parameter name, %s <!--%s-->' % (name, text) raise ParseError, (
('Invalid parameter name, %s <!--%s-->' % (name, text)), tag)
result[name]=value result[name]=value
...@@ -173,6 +175,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks ...@@ -173,6 +175,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
############################################################################ ############################################################################
# $Log: DT_Util.py,v $ # $Log: DT_Util.py,v $
# Revision 1.4 1997/09/25 18:56:39 jim
# fixed problem in reporting errors
#
# Revision 1.3 1997/09/22 14:42:50 jim # Revision 1.3 1997/09/22 14:42:50 jim
# added expr # added expr
# #
......
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