scripts: include __file__ in globals() (#24341)
This commit is contained in:
parent
240ba37244
commit
f0fd073219
|
@ -29,6 +29,7 @@ class Script(object):
|
|||
for path in paths:
|
||||
script_path = os.path.join(path, script_name + '.py')
|
||||
if os.path.exists(script_path):
|
||||
self.__file__ = script_path
|
||||
self.code = open(script_path).read()
|
||||
break
|
||||
else:
|
||||
|
@ -45,6 +46,7 @@ class Script(object):
|
|||
def __call__(self, *args):
|
||||
data = get_publisher().substitutions.get_context_variables().copy()
|
||||
data['args'] = args
|
||||
data['__file__'] = self.__file__
|
||||
code_object = compile(self.code, self.script_name, 'exec')
|
||||
eval(code_object, data)
|
||||
return data.get('result')
|
||||
|
|
Loading…
Reference in New Issue