@@ -209,14 +209,16 @@ def glob_files(load_paths, config):
209
209
rel_import_path = f"{ path } /mod_name"
210
210
if path == "" :
211
211
global_ctx_name = f"file.{ mod_name } "
212
+ fq_mod_name = mod_name
212
213
else :
213
214
global_ctx_name = f"{ path } .{ mod_name } "
215
+ fq_mod_name = global_ctx_name
214
216
if check_config :
215
217
_LOGGER .debug ("load_scripts: checking %s in %s" , mod_name , apps_config )
216
218
if not isinstance (apps_config , dict ) or mod_name not in apps_config :
217
219
_LOGGER .debug ("load_scripts: skipping %s because config not present" , this_path )
218
220
continue
219
- source_files .append ([global_ctx_name , this_path , rel_import_path ])
221
+ source_files .append ([global_ctx_name , this_path , rel_import_path , fq_mod_name ])
220
222
return source_files
221
223
222
224
load_paths = [
@@ -226,8 +228,11 @@ def glob_files(load_paths, config):
226
228
]
227
229
228
230
source_files = await hass .async_add_executor_job (glob_files , load_paths , config )
229
- for global_ctx_name , source_file , rel_import_path in source_files :
231
+ for global_ctx_name , source_file , rel_import_path , fq_mod_name in source_files :
230
232
global_ctx = GlobalContext (
231
- global_ctx_name , global_sym_table = {}, manager = GlobalContextMgr , rel_import_path = rel_import_path
233
+ global_ctx_name ,
234
+ global_sym_table = {"__name__" : fq_mod_name },
235
+ manager = GlobalContextMgr ,
236
+ rel_import_path = rel_import_path ,
232
237
)
233
238
await GlobalContextMgr .load_file (source_file , global_ctx )
0 commit comments