def reset_shell(shell, base_ns): """ Resets shell and loads project settings for Python """ projectPlugin = get_project_plugin() projectMap = projectPlugin.property('projectMap') if 'python' in projectMap: projectName = projectPlugin.property('projectName') projectMapPython = projectMap['python'] # Check Python version version = projectMapPython.get('version', None) if not is_version_compatible(version): msg = i18n('\n\nCannot load this project: %1. Python Version incompatible', projectName) shell.write(msg) sys.stdout.flush() return shell.reset() shell.user_ns.update(base_ns) shell.write(i18n('\n\nLoad project: %1', projectName)) extraPath = projectMapPython.get('extraPath', []) environs = projectMapPython.get('environs', {}) # Add Extra path add_extra_path(extraPath) # Add environs add_environs(environs) # Special treatment if projectMapPython.get('projectType', '').lower() == 'django': insert_django_objects(shell) # Print details sys.stdout.flush()
def projectFileNameChanged(*args, **kwargs): projectPlugin = get_project_plugin() projectMap = projectPlugin.property("projectMap") if "python" in projectMap: projectMapPython = projectMap["python"] version = projectMapPython.get("version", None) # Check Python version if not is_version_compatible(version): return extraPath = projectMapPython.get("extraPath", []) environs = projectMapPython.get("environs", {}) # Add Extra path add_extra_path(extraPath) # Add environs add_environs(environs) global pyplete pyplete = PyPlete(PythonCodeCompletionModel.createItemAutoComplete, sys.path)