Skip to content

Commit

Permalink
Newlines (and carriage-returns are now allowed in expressions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Fulton committed Mar 10, 1998
1 parent 3095a65 commit 65650cd
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions VSEval.py
@@ -1,7 +1,7 @@

"""Very Safe Python Expressions
"""
__rcs_id__='$Id: VSEval.py,v 1.9 1997/11/21 16:47:11 jim Exp $'
__rcs_id__='$Id: VSEval.py,v 1.10 1998/03/10 17:30:41 jim Exp $'

############################################################################
# Copyright
Expand All @@ -11,10 +11,12 @@
# rights reserved.
#
############################################################################
__version__='$Revision: 1.9 $'[11:-2]
__version__='$Revision: 1.10 $'[11:-2]

from string import join
import sys, gparse
from string import join, find, split, translate
import sys, gparse, string

nltosp=string.maketrans('\r\n',' ')

def default_slicer(env, s, *ind):
l=len(ind)
Expand Down Expand Up @@ -43,6 +45,8 @@ def careful_mul(env, *factors):
'__guarded_getslice__': default_slicer,
}



class Eval:
"""Provide a very-safe environment for evaluating expressions
Expand All @@ -69,6 +73,7 @@ def __init__(self, expr, globals=default_globals):
globals -- A global namespace.
"""

expr=translate(expr,nltosp)
self.expr=expr
self.globals=globals

Expand Down Expand Up @@ -118,6 +123,9 @@ def __call__(self, **kw):
############################################################################
#
# $Log: VSEval.py,v $
# Revision 1.10 1998/03/10 17:30:41 jim
# Newlines (and carriage-returns are now allowed in expressions.
#
# Revision 1.9 1997/11/21 16:47:11 jim
# Got rid of non-needed and non-portable import of new.
#
Expand Down

0 comments on commit 65650cd

Please sign in to comment.