Skip to content

Commit

Permalink
fixed problem in reporting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Sep 25, 1997
1 parent e03d12a commit a8007ee
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 16 deletions.
7 changes: 5 additions & 2 deletions DT_HTML.py
@@ -1,7 +1,7 @@

"""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
Expand Down Expand Up @@ -38,7 +38,7 @@ def parseTag(self, tagre, command=None, sargs=''):
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:
Expand Down Expand Up @@ -178,6 +178,9 @@ def manage_edit(self,data,
##########################################################################
#
# $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 ***
#
Expand Down
12 changes: 8 additions & 4 deletions DT_If.py
Expand Up @@ -110,8 +110,8 @@
# (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 *

Expand All @@ -136,12 +136,13 @@ def __init__(self, blocks):
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))
Expand Down Expand Up @@ -184,6 +185,9 @@ def render(self,md):
##########################################################################
#
# $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
#
Expand Down
13 changes: 9 additions & 4 deletions DT_In.py
Expand Up @@ -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
Expand Down Expand Up @@ -266,7 +266,7 @@
# (540) 371-6909
#
############################################################################
__version__='$Revision: 1.3 $'[11:-2]
__version__='$Revision: 1.4 $'[11:-2]

from DT_Util import *

Expand All @@ -286,13 +286,15 @@ def __init__(self, blocks):
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


Expand Down Expand Up @@ -718,6 +720,9 @@ def previous_batches(self):

############################################################################
# $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
#
Expand Down
17 changes: 11 additions & 6 deletions DT_Util.py
@@ -1,4 +1,4 @@
'''$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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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)
Expand All @@ -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

Expand All @@ -173,6 +175,9 @@ def parse_params(text,

############################################################################
# $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
#
Expand Down

0 comments on commit a8007ee

Please sign in to comment.