4040import sonar .platform as pf
4141
4242from sonar .util import types , cache
43- from sonar .util import project_utils as putils
44-
4543from sonar import exceptions , errcodes
4644from sonar import sqobject , components , qualitygates , qualityprofiles , tasks , settings , webhooks , devops
4745import sonar .permissions .permissions as perms
@@ -1359,22 +1357,14 @@ def count(endpoint: pf.Platform, params: types.ApiParams = None) -> int:
13591357def search (endpoint : pf .Platform , params : types .ApiParams = None , threads : int = 8 ) -> dict [str , Project ]:
13601358 """Searches projects in SonarQube
13611359
1362- :param Platform endpoint: Reference to the SonarQube platform
1363- :param ApiParams params: list of filter parameters to narrow down the search
1364- :param int threads: Number of threads to use for the search
1360+ :param endpoint: Reference to the SonarQube platform
1361+ :param params: list of parameters to narrow down the search
1362+ :returns: list of projects
13651363 """
13661364 new_params = {} if params is None else params .copy ()
1367- if not endpoint .is_sonarcloud () and not new_params . get ( "filter" , None ) :
1365+ if not endpoint .is_sonarcloud ():
13681366 new_params ["filter" ] = _PROJECT_QUALIFIER
1369- try :
1370- log .info ("Searching projects with parameters: %s" , str (new_params ))
1371- return sqobject .search_objects (endpoint = endpoint , object_class = Project , params = new_params , threads = threads )
1372- except exceptions .TooManyResults as e :
1373- log .warning (e .message )
1374- filter_1 , filter_2 = putils .split_loc_filter (new_params ["filter" ])
1375- return search (endpoint , params = {** new_params , "filter" : filter_1 }, threads = threads ) | search (
1376- endpoint , params = {** new_params , "filter" : filter_2 }, threads = threads
1377- )
1367+ return sqobject .search_objects (endpoint = endpoint , object_class = Project , params = new_params , threads = threads )
13781368
13791369
13801370def get_list (endpoint : pf .Platform , key_list : types .KeyList = None , threads : int = 8 , use_cache : bool = True ) -> dict [str , Project ]:
@@ -1385,8 +1375,8 @@ def get_list(endpoint: pf.Platform, key_list: types.KeyList = None, threads: int
13851375 :return: the list of all projects
13861376 :rtype: dict{key: Project}
13871377 """
1388- if key_list is None or len ( key_list ) == 0 or not use_cache :
1389- with _CLASS_LOCK :
1378+ with _CLASS_LOCK :
1379+ if key_list is None or len ( key_list ) == 0 or not use_cache :
13901380 log .info ("Listing projects" )
13911381 p_list = dict (sorted (search (endpoint = endpoint , threads = threads ).items ()))
13921382 return p_list
0 commit comments