Commit a78afc17 authored by Jim Fulton's avatar Jim Fulton

Expanded test function to allow any number of arguments.

parent 965d1d98
'''$Id: DT_Util.py,v 1.17 1997/11/19 15:42:47 jim Exp $''' '''$Id: DT_Util.py,v 1.18 1997/11/25 15:20:30 jim Exp $'''
############################################################################ ############################################################################
# Copyright # Copyright
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
# (540) 371-6909 # (540) 371-6909
# #
############################################################################ ############################################################################
__version__='$Revision: 1.17 $'[11:-2] __version__='$Revision: 1.18 $'[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
...@@ -127,9 +127,12 @@ for name in ('None', 'abs', 'chr', 'divmod', 'float', 'hash', 'hex', 'int', ...@@ -127,9 +127,12 @@ for name in ('None', 'abs', 'chr', 'divmod', 'float', 'hash', 'hex', 'int',
d['string']=string d['string']=string
d['math']=math d['math']=math
def test(cond, t, f): def test(*args):
if cond: return t l=len(args)
return f for i in range(1, l, 2):
if args[i-1]: return args[i]
if l%2: return args[-1]
d['test']=test d['test']=test
...@@ -287,6 +290,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks ...@@ -287,6 +290,9 @@ except: from pDocumentTemplate import InstanceDict, TemplateDict, render_blocks
############################################################################ ############################################################################
# $Log: DT_Util.py,v $ # $Log: DT_Util.py,v $
# Revision 1.18 1997/11/25 15:20:30 jim
# Expanded test function to allow any number of arguments.
#
# Revision 1.17 1997/11/19 15:42:47 jim # Revision 1.17 1997/11/19 15:42:47 jim
# added _ prefix to push and pop methods to make them private # added _ prefix to push and pop methods to make them private
# #
......
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