diff -r 549918576245 -r 8a0ec75b0f73 Utilities/ClassBrowsers/__init__.py --- a/Utilities/ClassBrowsers/__init__.py Sat Nov 18 12:35:13 2017 +0100 +++ b/Utilities/ClassBrowsers/__init__.py Sat Nov 18 18:27:25 2017 +0100 @@ -11,7 +11,10 @@ <ul> <li>CORBA IDL</li> -<li>Python</li> +<li>JavaScript</li> +<li>ProtoBuf</li> +<li>Python 2</li> +<li>Python 3</li> <li>Ruby</li> </ul> """ @@ -29,14 +32,17 @@ RB_SOURCE = 129 IDL_SOURCE = 130 JS_SOURCE = 131 +PROTO_SOURCE = 132 -SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE, IDL_SOURCE, JS_SOURCE] +SUPPORTED_TYPES = [PY_SOURCE, PTL_SOURCE, RB_SOURCE, IDL_SOURCE, JS_SOURCE, + PROTO_SOURCE] __extensions = { "IDL": [".idl"], "Python": [".py", ".pyw", ".ptl"], # currently not used "Ruby": [".rb"], "JavaScript": [".js"], + "ProtoBuf": [".proto"], } @@ -48,10 +54,14 @@ The real work of parsing the source file is delegated to the individual file parsers. - @param module name of the source file (string) - @param path path the file should be searched in (list of strings) - @param isPyFile flag indicating a Python file (boolean) + @param module name of the source file + @type str + @param path list of paths the file should be searched in + @type list of str + @param isPyFile flag indicating a Python file + @type bool @return the resulting dictionary + @rtype dict """ ext = os.path.splitext(module)[1].lower() path = [] if path is None else path[:] @@ -60,6 +70,10 @@ from . import idlclbr dictionary = idlclbr.readmodule_ex(module, path) idlclbr._modules.clear() + elif ext in __extensions["ProtoBuf"]: + from . import protoclbr + dictionary = protoclbr.readmodule_ex(module, path) + protoclbr._modules.clear() elif ext in __extensions["Ruby"]: from . import rbclbr dictionary = rbclbr.readmodule_ex(module, path) @@ -87,16 +101,20 @@ """ Module function to extend the Python module finding mechanism. - This function searches for files in the given path. If the filename - doesn't have an extension or an extension of .py, the normal search - implemented in the imp module is used. For all other supported files - only path is searched. + This function searches for files in the given list of paths. If the + file name doesn't have an extension or an extension of .py, the normal + Python search implemented in the imp module is used. For all other + supported files only the paths list is searched. - @param name filename or modulename to search for (string) - @param path search path (list of strings) - @param isPyFile flag indicating a Python file (boolean) + @param name file name or module name to search for + @type str + @param path search paths + @type list of str + @param isPyFile flag indicating a Python file + @type bool @return tuple of the open file, pathname and description. Description is a tuple of file suffix, file mode and file type) + @rtype tuple @exception ImportError The file or module wasn't found. """ ext = os.path.splitext(name)[1].lower() @@ -115,6 +133,13 @@ return (open(pathname), pathname, (ext, 'r', IDL_SOURCE)) raise ImportError + elif ext in __extensions["ProtoBuf"]: + for p in path: # only search in path + pathname = os.path.join(p, name) + if os.path.exists(pathname): + return (open(pathname), pathname, (ext, 'r', PROTO_SOURCE)) + raise ImportError + elif ext in __extensions["JavaScript"]: for p in path: # only search in path pathname = os.path.join(p, name)