mirror of
https://github.com/panda3d/panda3d.git
synced 2026-03-09 10:49:01 -05:00
Commit patch by cfsworks to clean up use of exec() and eval()
This commit is contained in:
@@ -107,9 +107,7 @@ MsgName2Id = {
|
||||
MsgId2Names = invertDictLossless(MsgName2Id)
|
||||
|
||||
# put msg names in module scope, assigned to msg value
|
||||
for name, value in MsgName2Id.items():
|
||||
exec('%s = %s' % (name, value))
|
||||
del name, value
|
||||
globals().update(MsgName2Id)
|
||||
|
||||
# These messages are ignored when the client is headed to the quiet zone
|
||||
QUIET_ZONE_IGNORED_LIST = [
|
||||
|
||||
@@ -26,6 +26,4 @@ MsgName2Id = {
|
||||
MsgId2Names = invertDictLossless(MsgName2Id)
|
||||
|
||||
# put msg names in module scope, assigned to msg value
|
||||
for name, value in MsgName2Id.items():
|
||||
exec('%s = %s' % (name, value))
|
||||
del name, value
|
||||
globals().update(MsgName2Id)
|
||||
|
||||
@@ -113,8 +113,7 @@ class OnscreenGeom(DirectObject, NodePath):
|
||||
for option, value in kw.items():
|
||||
# Use option string to access setter function
|
||||
try:
|
||||
setter = eval('self.set' +
|
||||
string.upper(option[0]) + option[1:])
|
||||
setter = getattr(self, 'set' + option[0].upper() + option[1:])
|
||||
if (((setter == self.setPos) or
|
||||
(setter == self.setHpr) or
|
||||
(setter == self.setScale)) and
|
||||
@@ -133,7 +132,7 @@ class OnscreenGeom(DirectObject, NodePath):
|
||||
def cget(self, option):
|
||||
# Get current configuration setting.
|
||||
# This is for compatibility with DirectGui functions
|
||||
getter = eval('self.get' + string.upper(option[0]) + option[1:])
|
||||
getter = getattr(self, 'get' + option[0].upper() + option[1:])
|
||||
return getter()
|
||||
|
||||
# Allow index style refererences
|
||||
|
||||
@@ -130,8 +130,7 @@ class OnscreenImage(DirectObject, NodePath):
|
||||
for option, value in kw.items():
|
||||
# Use option string to access setter function
|
||||
try:
|
||||
setter = eval('self.set' +
|
||||
string.upper(option[0]) + option[1:])
|
||||
setter = getattr(self, 'set' + option[0].upper() + option[1:])
|
||||
if (((setter == self.setPos) or
|
||||
(setter == self.setHpr) or
|
||||
(setter == self.setScale)) and
|
||||
@@ -150,7 +149,7 @@ class OnscreenImage(DirectObject, NodePath):
|
||||
def cget(self, option):
|
||||
# Get current configuration setting.
|
||||
# This is for compatibility with DirectGui functions
|
||||
getter = eval('self.get' + string.upper(option[0]) + option[1:])
|
||||
getter = getattr(self, 'get' + option[0].upper() + option[1:])
|
||||
return getter()
|
||||
|
||||
# Allow index style refererences
|
||||
|
||||
@@ -381,8 +381,7 @@ class OnscreenText(DirectObject, NodePath):
|
||||
for option, value in kw.items():
|
||||
# Use option string to access setter function
|
||||
try:
|
||||
setter = eval('self.set' +
|
||||
string.upper(option[0]) + option[1:])
|
||||
setter = getattr(self, 'set' + option[0].upper() + option[1:])
|
||||
if setter == self.setPos:
|
||||
setter(value[0], value[1])
|
||||
else:
|
||||
@@ -397,7 +396,7 @@ class OnscreenText(DirectObject, NodePath):
|
||||
def cget(self, option):
|
||||
# Get current configuration setting.
|
||||
# This is for compatibility with DirectGui functions
|
||||
getter = eval('self.get' + string.upper(option[0]) + option[1:])
|
||||
getter = getattr(self, 'get' + option[0].upper() + option[1:])
|
||||
return getter()
|
||||
|
||||
def setAlign(self, align):
|
||||
|
||||
@@ -189,9 +189,9 @@ class ObjectMgrBase:
|
||||
if funcName.startswith('.'):
|
||||
# when it's using default objectHandler
|
||||
if self.editor:
|
||||
func = Functor(eval("self.editor.objectHandler%s"%funcName))
|
||||
func = Functor(getattr(self.editor, "objectHandler%s"%funcName))
|
||||
else: # when loaded outside of LE
|
||||
func = Functor(eval("base.objectHandler%s"%funcName))
|
||||
func = Functor(getattr(base, "objectHandler%s"%funcName))
|
||||
else:
|
||||
# when it's not using default objectHandler, whole name of the handling obj
|
||||
# should be included in function name
|
||||
@@ -686,11 +686,11 @@ class ObjectMgrBase:
|
||||
if type(funcName) == types.StringType:
|
||||
if funcName.startswith('.'):
|
||||
if self.editor:
|
||||
func = Functor(eval("self.editor.objectHandler%s"%funcName), **kwargs)
|
||||
undoFunc = Functor(eval("self.editor.objectHandler%s"%funcName), **undoKwargs)
|
||||
func = Functor(getattr(self.editor, "objectHandler%s"%funcName), **kwargs)
|
||||
undoFunc = Functor(getattr(self.editor, "objectHandler%s"%funcName), **undoKwargs)
|
||||
else: # when loaded outside of LE
|
||||
func = Functor(eval("base.objectHandler%s"%funcName), **kwargs)
|
||||
undoFunc = Functor(eval("base.objectHandler%s"%funcName), **undoKwargs)
|
||||
func = Functor(getattr(base, "objectHandler%s"%funcName), **kwargs)
|
||||
undoFunc = Functor(getattr(base, ".objectHandler%s"%funcName), **undoKwargs)
|
||||
else:
|
||||
func = Functor(eval(funcName), **kwargs)
|
||||
undoFunc = Functor(eval(funcName), **undoKwargs)
|
||||
|
||||
@@ -354,7 +354,7 @@ class Particles(ParticleSystem):
|
||||
else:
|
||||
file.write(targ+'.renderer.setColorBlendMode(ColorBlendAttrib.%s)\n' % cbmLut[cbMode])
|
||||
cim = self.renderer.getColorInterpolationManager()
|
||||
segIdList = eval('['+cim.getSegmentIdList().replace(' ',', ')+']')
|
||||
segIdList = [int(seg) for seg in cim.getSegmentIdList().split()]
|
||||
for sid in segIdList:
|
||||
seg = cim.getSegment(sid)
|
||||
if seg.isEnabled():
|
||||
@@ -457,7 +457,7 @@ class Particles(ParticleSystem):
|
||||
else:
|
||||
file.write(targ+'.renderer.setColorBlendMode(ColorBlendAttrib.%s)\n' % cbmLut[cbMode])
|
||||
cim = self.renderer.getColorInterpolationManager()
|
||||
segIdList = eval('['+cim.getSegmentIdList().replace(' ',', ')+']')
|
||||
segIdList = [int(seg) for seg in cim.getSegmentIdList().split()]
|
||||
for sid in segIdList:
|
||||
seg = cim.getSegment(sid)
|
||||
if seg.isEnabled():
|
||||
|
||||
@@ -749,10 +749,7 @@ def _encode(s, encoding):
|
||||
except AttributeError:
|
||||
return s # 1.5.2: assume the string uses the right encoding
|
||||
|
||||
if sys.version[:3] == "1.5":
|
||||
_escape = re.compile(r"[&<>\"\x80-\xff]+") # 1.5.2
|
||||
else:
|
||||
_escape = re.compile(eval(r'u"[&<>\"\u0080-\uffff]+"'))
|
||||
_escape = re.compile(u"[&<>\"\u0080-\uffff]+")
|
||||
|
||||
_escape_map = {
|
||||
"&": "&",
|
||||
|
||||
@@ -4188,7 +4188,7 @@ def unescapeHtmlString(s):
|
||||
char = ' '
|
||||
elif char == '%':
|
||||
if i < (len(s)-2):
|
||||
num = eval('0x' + s[i+1:i+3])
|
||||
num = int(s[i+1:i+3], 16)
|
||||
char = chr(num)
|
||||
i += 2
|
||||
i += 1
|
||||
|
||||
Reference in New Issue
Block a user