Wed, 09 Nov 2022 10:59:01 +0100
Modified most of the importlib.import_module() calls to use relative imports.
--- a/src/eric7/Debugger/DebugServer.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/Debugger/DebugServer.py Wed Nov 09 10:59:01 2022 +0100 @@ -399,7 +399,7 @@ Private method to register the available internal debugger interfaces. """ for name, interface in DebuggerInterfaces.items(): - mod = importlib.import_module("eric7.Debugger.{0}".format(interface)) + mod = importlib.import_module(".{0}".format(interface), __package__) self.registerDebuggerInterface(name, mod.getRegistryData) def getSupportedLanguages(self, shellOnly=False):
--- a/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/Plugins/CheckerPlugins/CodeStyleChecker/Security/Checks/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -35,7 +35,7 @@ for checkerModule in checkerModules: try: - mod = importlib.import_module("Security.Checks.{0}".format(checkerModule)) + mod = importlib.import_module(".{0}".format(checkerModule), __package__) except ImportError: continue
--- a/src/eric7/Preferences/ConfigurationDialog.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/Preferences/ConfigurationDialog.py Wed Nov 09 10:59:01 2022 +0100 @@ -1120,7 +1120,7 @@ """ try: mod = importlib.import_module( - "eric7.Preferences.ConfigurationPages.{0}".format(name) + ".ConfigurationPages.{0}".format(name), __package__ ) return mod except ImportError:
--- a/src/eric7/QScintilla/DocstringGenerator/BaseDocstringGenerator.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/QScintilla/DocstringGenerator/BaseDocstringGenerator.py Wed Nov 09 10:59:01 2022 +0100 @@ -143,16 +143,14 @@ @rtype str """ generatorModuleMapping = { - "ericdoc": "EricdocGenerator", - "numpydoc": "NumpydocGenerator", - "goodledoc": "GoogledocGenerator", - "sphinxdoc": "SphinxdocGenerator", + "ericdoc": ".EricdocGenerator", + "numpydoc": ".NumpydocGenerator", + "goodledoc": ".GoogledocGenerator", + "sphinxdoc": ".SphinxdocGenerator", } if docstringType in generatorModuleMapping: mod = importlib.import_module( - "eric7.QScintilla.DocstringGenerator.{0}".format( - generatorModuleMapping[docstringType] - ) + generatorModuleMapping[docstringType], __package__ ) return mod.generateDoc(functionInfo, self.editor)
--- a/src/eric7/QScintilla/Exporters/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/QScintilla/Exporters/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -42,17 +42,15 @@ (QScintilla.Exporter.Exporter) """ exporterMapping = { - "HTML": "ExporterHTML", - "ODT": "ExporterODT", - "PDF": "ExporterPDF", - "RTF": "ExporterRTF", - "TeX": "ExporterTEX", + "HTML": ".ExporterHTML", + "ODT": ".ExporterODT", + "PDF": ".ExporterPDF", + "RTF": ".ExporterRTF", + "TeX": ".ExporterTEX", } with contextlib.suppress(ImportError): if exporterFormat in exporterMapping: - mod = importlib.import_module( - "eric7.QScintilla.Exporters.{0}".format(exporterMapping[exporterFormat]) - ) + mod = importlib.import_module(exporterMapping[exporterFormat], __package__) return mod.createExporter(editor) return None
--- a/src/eric7/QScintilla/Lexers/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/QScintilla/Lexers/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -290,50 +290,50 @@ """ if not pyname: languageLexerMapping = { - "Bash": "LexerBash", - "Batch": "LexerBatch", - "C#": "LexerCSharp", - "C++": "LexerCPP", - "CMake": "LexerCMake", - "CoffeeScript": "LexerCoffeeScript", - "CSS": "LexerCSS", - "Cython": "LexerPython", - "D": "LexerD", - "Diff": "LexerDiff", - "Fortran": "LexerFortran", - "Fortran77": "LexerFortran77", - "Gettext": "LexerPO", - "HTML": "LexerHTML", - "IDL": "LexerIDL", - "Java": "LexerJava", - "JavaScript": "LexerJavaScript", - "JSON": "LexerJSON", - "Lua": "LexerLua", - "Makefile": "LexerMakefile", - "Markdown": "LexerMarkdown", - "Matlab": "LexerMatlab", - "MicroPython": "LexerPython", - "Octave": "LexerOctave", - "Pascal": "LexerPascal", - "Perl": "LexerPerl", - "PostScript": "LexerPostScript", - "Properties": "LexerProperties", - "Povray": "LexerPOV", - "Python": "LexerPython", - "Python3": "LexerPython", - "QSS": "LexerQSS", - "Ruby": "LexerRuby", - "SQL": "LexerSQL", - "TCL": "LexerTCL", - "TeX": "LexerTeX", - "VHDL": "LexerVHDL", - "XML": "LexerXML", - "YAML": "LexerYAML", + "Bash": ".LexerBash", + "Batch": ".LexerBatch", + "C#": ".LexerCSharp", + "C++": ".LexerCPP", + "CMake": ".LexerCMake", + "CoffeeScript": ".LexerCoffeeScript", + "CSS": ".LexerCSS", + "Cython": ".LexerPython", + "D": ".LexerD", + "Diff": ".LexerDiff", + "Fortran": ".LexerFortran", + "Fortran77": ".LexerFortran77", + "Gettext": ".LexerPO", + "HTML": ".LexerHTML", + "IDL": ".LexerIDL", + "Java": ".LexerJava", + "JavaScript": ".LexerJavaScript", + "JSON": ".LexerJSON", + "Lua": ".LexerLua", + "Makefile": ".LexerMakefile", + "Markdown": ".LexerMarkdown", + "Matlab": ".LexerMatlab", + "MicroPython": ".LexerPython", + "Octave": ".LexerOctave", + "Pascal": ".LexerPascal", + "Perl": ".LexerPerl", + "PostScript": ".LexerPostScript", + "Properties": ".LexerProperties", + "Povray": ".LexerPOV", + "Python": ".LexerPython", + "Python3": ".LexerPython", + "QSS": ".LexerQSS", + "Ruby": ".LexerRuby", + "SQL": ".LexerSQL", + "TCL": ".LexerTCL", + "TeX": ".LexerTeX", + "VHDL": ".LexerVHDL", + "XML": ".LexerXML", + "YAML": ".LexerYAML", } try: if language in languageLexerMapping: mod = importlib.import_module( - "eric7.QScintilla.Lexers.{0}".format(languageLexerMapping[language]) + languageLexerMapping[language], __package__ ) if mod: return mod.createLexer(language, parent)
--- a/src/eric7/QScintilla/MarkupProviders/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/QScintilla/MarkupProviders/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -22,7 +22,7 @@ @return markup provider @rtype MarkupBase """ - markupModule = "MarkupBase" + markupModule = ".MarkupBase" if editor is not None: fn = editor.getFileName() @@ -34,19 +34,17 @@ extension in Preferences.getEditor("PreviewHtmlFileNameExtensions") or editor.getLanguage() == "HTML" ): - markupModule = "HtmlProvider" + markupModule = ".HtmlProvider" elif ( extension in Preferences.getEditor("PreviewMarkdownFileNameExtensions") or editor.getLanguage().lower() == "markdown" ): - markupModule = "MarkdownProvider" + markupModule = ".MarkdownProvider" elif ( extension in Preferences.getEditor("PreviewRestFileNameExtensions") or editor.getLanguage().lower() == "restructuredtext" ): - markupModule = "RestructuredTextProvider" + markupModule = ".RestructuredTextProvider" - mod = importlib.import_module( - "eric7.QScintilla.MarkupProviders.{0}".format(markupModule) - ) + mod = importlib.import_module(markupModule, __package__) return mod.createProvider()
--- a/src/eric7/QScintilla/TypingCompleters/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/QScintilla/TypingCompleters/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -20,20 +20,16 @@ @return reference to the instanciated lexer object (QsciLexer) """ languageCompleterMapping = { - "Python": "CompleterPython", - "Python3": "CompleterPython", - "MicroPython": "CompleterPython", - "Cython": "CompleterPython", - "Ruby": "CompleterRuby", - "YAML": "CompleterYaml", + "Python": ".CompleterPython", + "Python3": ".CompleterPython", + "MicroPython": ".CompleterPython", + "Cython": ".CompleterPython", + "Ruby": ".CompleterRuby", + "YAML": ".CompleterYaml", } if language in languageCompleterMapping: - mod = importlib.import_module( - "eric7.QScintilla.TypingCompleters.{0}".format( - languageCompleterMapping[language] - ) - ) + mod = importlib.import_module(languageCompleterMapping[language], __package__) if mod: return mod.createCompleter(editor, parent)
--- a/src/eric7/Utilities/ClassBrowsers/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/Utilities/ClassBrowsers/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -59,17 +59,15 @@ @rtype module """ typeMapping = { - "idl": "idlclbr", - "javascript": "jsclbr", - "protobuf": "protoclbr", - "python": "pyclbr", - "ruby": "rbclbr", + "idl": ".idlclbr", + "javascript": ".jsclbr", + "protobuf": ".protoclbr", + "python": ".pyclbr", + "ruby": ".rbclbr", } if moduleType in typeMapping: - mod = importlib.import_module( - "eric7.Utilities.ClassBrowsers.{0}".format(typeMapping[moduleType]) - ) + mod = importlib.import_module(typeMapping[moduleType], __package__) return mod return None
--- a/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/__init__.py Wed Nov 09 10:37:21 2022 +0100 +++ b/src/eric7/WebBrowser/Bookmarks/BookmarksImporters/__init__.py Wed Nov 09 10:59:01 2022 +0100 @@ -98,22 +98,18 @@ @exception ValueError raised to indicate an unsupported importer """ importerMapping = { - "chrome": "ChromeImporter", - "chromium": "ChromeImporter", - "e5browser": "XbelImporter", - "firefox": "FirefoxImporter", - "html": "HtmlImporter", - "ie": "IExplorerImporter", - "konqueror": "XbelImporter", - "opera": "OperaImporter", - "safari": "SafariImporter", - "xbel": "XbelImporter", + "chrome": ".ChromeImporter", + "chromium": ".ChromeImporter", + "e5browser": ".XbelImporter", + "firefox": ".FirefoxImporter", + "html": ".HtmlImporter", + "ie": ".IExplorerImporter", + "konqueror": ".XbelImporter", + "opera": ".OperaImporter", + "safari": ".SafariImporter", + "xbel": ".XbelImporter", } if sourceId in importerMapping: - return importlib.import_module( - "eric7.WebBrowser.Bookmarks.BookmarksImporters.{0}".format( - importerMapping[sourceId] - ) - ) + return importlib.import_module(importerMapping[sourceId], __package__) raise ValueError("Invalid importer ID given ({0}).".format(sourceId))