MCPcopy Create free account
hub / github.com/kubernetes-client/python / __search

Method __search

kubernetes/base/dynamic/discovery.py:364–387  ·  view source on GitHub ↗
(self, parts, resources)

Source from the content-addressed store, hash-verified

362 return list(map(lambda x: x or '*', items))
363
364 def __search(self, parts, resources):
365 part = parts[0]
366 resourcePart = resources.get(part)
367
368 if part != '*' and resourcePart:
369 if isinstance(resourcePart, ResourceGroup):
370 return self.__search(parts[1:], resourcePart.resources)
371 elif isinstance(resourcePart, dict):
372 return self.__search(parts[1:], resourcePart)
373 else:
374 if parts[1] != '*' and isinstance(parts[1], dict):
375 for _resource in resourcePart:
376 for term, value in parts[1].items():
377 if getattr(_resource, term) == value:
378 return [_resource]
379 return []
380 else:
381 return resourcePart
382 elif part == '*':
383 matches = []
384 for key in resources.keys():
385 matches.extend(self.__search([key] + parts[1:], resources))
386 return matches
387 return []
388
389 def __iter__(self):
390 for _, groups in self.__resources.items():

Callers 1

searchMethod · 0.95

Calls 2

getMethod · 0.45
itemsMethod · 0.45

Tested by

no test coverage detected