Skip to content

Commit

Permalink
Fixed bug in handling: %(foo)d
Browse files Browse the repository at this point in the history
and in handling <!--#var foo--> where foo is a tuple.
  • Loading branch information
Jim Fulton committed Apr 14, 1998
1 parent 7af4605 commit 322306e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions DT_Var.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
''' # '
__rcs_id__='$Id: DT_Var.py,v 1.13 1998/04/02 19:06:21 jim Exp $'
__rcs_id__='$Id: DT_Var.py,v 1.14 1998/04/14 11:58:21 jim Exp $'

############################################################################
# Copyright
Expand Down Expand Up @@ -168,7 +168,7 @@
# (540) 371-6909
#
############################################################################
__version__='$Revision: 1.13 $'[11:-2]
__version__='$Revision: 1.14 $'[11:-2]

from DT_Util import *

Expand All @@ -178,7 +178,7 @@ class Var:
name='var'
expr=None

def __init__(self, args, fmt=''):
def __init__(self, args, fmt='s'):
args = parse_params(args, name='', lower=1, upper=1, expr='',
capitalize=1, spacify=1, null='', fmt='s',
size=0, etc='...', thousands_commas=1,
Expand All @@ -197,7 +197,7 @@ def __init__(self, args, fmt=''):
self.__name__, self.expr = name, expr
self.fmt = fmt

if len(args)==1:
if len(args)==1 and fmt=='s':
if expr is None: expr=name
else: expr=expr.eval
self.simple_form=expr,
Expand Down Expand Up @@ -242,7 +242,9 @@ def render(self, md):
else: val = fmt % val

# finally, pump it through the actual string format...
val = ('%'+self.fmt) % val
fmt=self.fmt
if fmt=='s': val=str(val)
else: val = ('%'+self.fmt) % (val,)

# next, look for upper, lower, etc
for f in self.modifiers: val=f(val)
Expand Down Expand Up @@ -368,6 +370,10 @@ def spacify(val): return gsub('_', ' ', val)

############################################################################
# $Log: DT_Var.py,v $
# Revision 1.14 1998/04/14 11:58:21 jim
# Fixed bug in handling: %(foo)d
# and in handling <!--#var foo--> where foo is a tuple.
#
# Revision 1.13 1998/04/02 19:06:21 jim
# *** empty log message ***
#
Expand Down

0 comments on commit 322306e

Please sign in to comment.