--- a/src/eric7/WebBrowser/OpenSearch/OpenSearchManager.py Fri Dec 22 13:57:47 2023 +0100 +++ b/src/eric7/WebBrowser/OpenSearch/OpenSearchManager.py Fri Dec 22 17:24:07 2023 +0100 @@ -37,7 +37,8 @@ """ Constructor - @param parent reference to the parent object (QObject) + @param parent reference to the parent object + @type QObject """ if parent is None: parent = ericApp() @@ -64,7 +65,8 @@ """ Public method to get the name of the current search engine. - @return name of the current search engine (string) + @return name of the current search engine + @rtype str """ return self.__current @@ -72,7 +74,8 @@ """ Public method to set the current engine by name. - @param name name of the new current engine (string) + @param name name of the new current engine + @type str """ if name not in self.__engines: return @@ -85,7 +88,8 @@ """ Public method to get a reference to the current engine. - @return reference to the current engine (OpenSearchEngine) + @return reference to the current engine + @rtype OpenSearchEngine """ if not self.__current or self.__current not in self.__engines: return None @@ -96,7 +100,8 @@ """ Public method to set the current engine. - @param engine reference to the new current engine (OpenSearchEngine) + @param engine reference to the new current engine + @type OpenSearchEngine """ if engine is None: return @@ -110,8 +115,10 @@ """ Public method to get a reference to the named engine. - @param name name of the engine (string) - @return reference to the engine (OpenSearchEngine) + @param name name of the engine + @type str + @return reference to the engine + @rtype OpenSearchEngine """ if name not in self.__engines: return None @@ -122,8 +129,10 @@ """ Public method to check, if an engine exists. - @param name name of the engine (string) - @return flag indicating an existing engine (boolean) + @param name name of the engine + @type str + @return flag indicating an existing engine + @rtype bool """ return name in self.__engines @@ -131,7 +140,8 @@ """ Public method to get a list of all engine names. - @return sorted list of all engine names (list of strings) + @return sorted list of all engine names + @rtype list of str """ return sorted(self.__engines) @@ -139,7 +149,8 @@ """ Public method to get the number of available engines. - @return number of engines (integer) + @return number of engines + @rtype int """ return len(self.__engines) @@ -148,9 +159,11 @@ Public method to add a new search engine. @param engine URL of the engine definition file (QUrl) or - name of a file containing the engine definition (string) + name of a file containing the engine definition + @type str or reference to an engine object (OpenSearchEngine) - @return flag indicating success (boolean) + @return flag indicating success + @rtype bool """ from .OpenSearchEngine import OpenSearchEngine @@ -165,8 +178,10 @@ """ Private method to add a new search engine given its URL. - @param url URL of the engine definition file (QUrl) - @return flag indicating success (boolean) + @param url URL of the engine definition file + @type QUrl + @return flag indicating success + @rtype bool """ if not url.isValid(): return False @@ -183,8 +198,9 @@ Private method to add a new search engine given a filename. @param filename name of a file containing the engine definition - (string) - @return flag indicating success (boolean) + @type str + @return flag indicating success + @rtype bool """ from .OpenSearchReader import OpenSearchReader @@ -205,8 +221,10 @@ Private method to add a new search engine given a reference to an engine. - @param engine reference to an engine object (OpenSearchEngine) - @return flag indicating success (boolean) + @param engine reference to an engine object + @type OpenSearchEngine + @return flag indicating success + @rtype bool """ if engine is None: return False @@ -292,7 +310,8 @@ """ Public method to remove an engine. - @param name name of the engine (string) + @param name name of the engine + @type str """ if len(self.__engines) <= 1: return @@ -319,8 +338,10 @@ """ Public method to generate a valid engine file name. - @param engineName name of the engine (string) - @return valid engine file name (string) + @param engineName name of the engine + @type str + @return valid engine file name + @rtype str """ fileName = "" @@ -341,7 +362,8 @@ """ Public method to save the search engine definitions to files. - @param dirName name of the directory to write the files to (string) + @param dirName name of the directory to write the files to + @type str """ from .OpenSearchWriter import OpenSearchWriter @@ -382,8 +404,10 @@ """ Public method to load the search engine definitions from files. - @param dirName name of the directory to load the files from (string) - @return flag indicating success (boolean) + @param dirName name of the directory to load the files from + @type str + @return flag indicating success + @rtype bool """ if not os.path.exists(dirName): return False @@ -440,7 +464,8 @@ Public method to determine the directory containing the search engine descriptions. - @return directory name (string) + @return directory name + @rtype str """ return os.path.join(Globals.getConfigDir(), "web_browser", "searchengines") @@ -448,8 +473,10 @@ """ Private method to confirm the addition of a new search engine. - @param engine reference to the engine to be added (OpenSearchEngine) - @return flag indicating the engine shall be added (boolean) + @param engine reference to the engine to be added + @type OpenSearchEngine + @return flag indicating the engine shall be added + @rtype bool """ if engine is None or not engine.isValid(): return False @@ -505,8 +532,10 @@ """ Public method to get the search URL for a keyword search. - @param keywordSearch search string for keyword search (string) - @return search URL (QUrl) + @param keywordSearch search string for keyword search + @type str + @return search URL + @rtype QUrl """ try: keyword, term = keywordSearch.split(" ", 1) @@ -526,8 +555,10 @@ """ Public method to get the engine for a keyword. - @param keyword keyword to get engine for (string) - @return reference to the search engine object (OpenSearchEngine) + @param keyword keyword to get engine for + @type str + @return reference to the search engine object + @rtype OpenSearchEngine """ if keyword and keyword in self.__keywords: return self.__keywords[keyword] @@ -538,9 +569,11 @@ """ Public method to set the engine for a keyword. - @param keyword keyword to get engine for (string) - @param engine reference to the search engine object (OpenSearchEngine) - or None to remove the keyword + @param keyword keyword to get engine for + @type str + @param engine reference to the search engine object or None to + remove the keyword + @type OpenSearchEngine """ if not keyword: return @@ -557,8 +590,10 @@ """ Public method to get the keywords for a given engine. - @param engine reference to the search engine object (OpenSearchEngine) - @return list of keywords (list of strings) + @param engine reference to the search engine object + @type OpenSearchEngine + @return list of keywords + @rtype list of str """ return [k for k in self.__keywords if self.__keywords[k] == engine] @@ -566,8 +601,10 @@ """ Public method to set the keywords for an engine. - @param engine reference to the search engine object (OpenSearchEngine) - @param keywords list of keywords (list of strings) + @param engine reference to the search engine object + @type OpenSearchEngine + @param keywords list of keywords + @type list of str """ if engine is None: return