From ac738ff92361e51f48b3f0452239043412710a9f Mon Sep 17 00:00:00 2001 From: Cyrille Bougot Date: Mon, 25 Nov 2024 10:06:27 +0100 Subject: [PATCH] Fixed an issue when trying to open a Python module with openCodeFile function --- addon/globalPlugins/ndtt/fileOpener.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/addon/globalPlugins/ndtt/fileOpener.py b/addon/globalPlugins/ndtt/fileOpener.py index a94e7e6..2ee66df 100644 --- a/addon/globalPlugins/ndtt/fileOpener.py +++ b/addon/globalPlugins/ndtt/fileOpener.py @@ -254,7 +254,11 @@ def openObject(objPath): tokens = objPath.split('.') for iToken in range(len(tokens)): modName = '.'.join(tokens[0:iToken + 1]) - objName = '.'.join(tokens[iToken + 1:]) + inModuleTokens = tokens[iToken + 1:] + if inModuleTokens: + objName = '.'.join(inModuleTokens) + else: + objName = None try: mod = importFunction(modName) # Python 2 raise ImportError for non-existing modules; Python 3 raises ModuleNotFoundError instead. @@ -271,7 +275,7 @@ def openObject(objPath): def openObjectInModule(objName, mod): - tokens = objName.split('.') + tokens = objName.split('.') if objName else [] obj = mod try: for attr in tokens: