def setEnvObj(self, obj):
"""Sets the environment for the given object. If object is a sequence
then each pair of elements k, v is added as env[k] = v.
If object is a map then the environmnent is updated.
Other object types are not supported
The elements which are strings are 'python evaluated'
@throws TypeError is obj is not a sequence or a map
@param[in] obj object to be added to the environment
@return a dict representing the added environment"""
if operator.isSequenceType(obj) and \
not isinstance(obj, (str, unicode)):
obj = self._dictFromSequence(obj)
elif not operator.isMappingType(obj):
raise TypeError("obj parameter must be a sequence or a map")
obj = self._encode(obj)
for k, v in obj.iteritems():
self._setOneEnv(k, v)
return obj
评论列表
文章目录