def get_env_dict_from_string(s):
"""What it sounds like.
http://stackoverflow.com/questions/5362771/load-module-from-string-in-python
"""
try:
del sys.modules['requester.env'] # this avoids a subtle bug, DON'T REMOVE
except KeyError:
pass
if not s:
return {}
env = imp.new_module('requester.env')
try:
exec(s, env.__dict__)
except Exception as e:
sublime.error_message('EnvBlock Error:\n{}'.format(e))
return {}
else:
return dict(env.__dict__)
评论列表
文章目录