src/eric7/Utilities/ClassBrowsers/__init__.py

branch
server
changeset 10592
2bada76be1a6
parent 10496
f9925e08dbce
child 11090
f5f5f5803935
--- a/src/eric7/Utilities/ClassBrowsers/__init__.py	Mon Feb 19 15:34:54 2024 +0100
+++ b/src/eric7/Utilities/ClassBrowsers/__init__.py	Mon Feb 19 15:56:51 2024 +0100
@@ -108,7 +108,7 @@
     return None
 
 
-def readmodule(module, path=None, isPyFile=False):
+def readmodule(module, searchPath=None, isPyFile=False):
     """
     Function to read a source file and return a dictionary of classes, functions,
     modules, etc. .
@@ -118,7 +118,7 @@
 
     @param module name of the source file
     @type str
-    @param path list of paths the file should be searched in
+    @param searchPath list of paths the file should be searched in
     @type list of str
     @param isPyFile flag indicating a Python file
     @type bool
@@ -126,13 +126,13 @@
     @rtype dict
     """
     ext = os.path.splitext(module)[1].lower()
-    path = [] if path is None else path[:]
+    searchPath = [] if searchPath is None else searchPath[:]
 
     if not isPyFile:
         for classBrowserName in ClassBrowserRegistry:
             if ext in ClassBrowserRegistry[classBrowserName]["Extensions"]:
                 return ClassBrowserRegistry[classBrowserName]["ReadModule"](
-                    module, path
+                    module, searchPath
                 )
 
     if ext in __extensions["Ruby"]:
@@ -145,7 +145,7 @@
 
     classBrowserModule = getClassBrowserModule(moduleType)
     dictionary = (
-        classBrowserModule.readmodule_ex(module, path, isTypeFile=isPyFile)
+        classBrowserModule.readmodule_ex(module, searchPath, isTypeFile=isPyFile)
         if classBrowserModule
         else {}
     )
@@ -244,6 +244,34 @@
     raise ImportError
 
 
+def determineSourceType(name, isPyFile=False):
+    """
+    Function to determine the type of a source file given its name.
+
+    @param name file name or module name
+    @type str
+    @param isPyFile flag indicating a Python file (defaults to False)
+    @type bool (optional)
+    @return source file type
+    @rtype int
+    """
+    ext = os.path.splitext(name)[1].lower()
+
+    if ext in __extensions["Ruby"]:
+        sourceType = RB_SOURCE
+    elif ext == ".ptl":
+        sourceType = PTL_SOURCE
+    elif (
+        name.lower().endswith(tuple(Preferences.getPython("Python3Extensions")))
+        or isPyFile
+    ):
+        sourceType = PY_SOURCE
+    else:
+        sourceType = UNKNOWN_SOURCE
+
+    return sourceType
+
+
 def getIcon(filename):
     """
     Function to get an icon name for the given file (only for class browsers provided

eric ide

mercurial