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

fixed problem in reporting errors

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