boolean (@NotNull PythonRunConfiguration configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final Location location = context.getLocation(); if (location == null) return false; final PsiFile script = location.getPsiElement().getContainingFile(); if (!isAvailable(location, script)) return false; final VirtualFile vFile = script.getVirtualFile(); if (vFile == null) return false; configuration.setScriptName(vFile.getPath()); final VirtualFile parent = vFile.getParent(); if (parent != null && StringUtil.isEmpty(configuration.getWorkingDirectory())) { configuration.setWorkingDirectory(parent.getPath()); } final Module module = ModuleUtilCore.findModuleForPsiElement(script); if (module != null) { configuration.setUseModuleSdk(true); configuration.setModule(module); } configuration.setGeneratedName(); return true; }