MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / get_instance_from_cache

Function get_instance_from_cache

pager_lib/getmac/getmac.py:1341–1362  ·  view source on GitHub ↗

Get the class for a named Method from the caches. METHOD_CACHE is checked first, and if that fails, then any entries in FALLBACK_CACHE are checked. If both fail, None is returned. Args: method_type: method type to initialize the cache for. Allowed values ar

(method_type, method_name)

Source from the content-addressed store, hash-verified

1339
1340
1341def get_instance_from_cache(method_type, method_name):
1342 # type: (str, str) -> Optional[Method]
1343 """
1344 Get the class for a named Method from the caches.
1345
1346 METHOD_CACHE is checked first, and if that fails,
1347 then any entries in FALLBACK_CACHE are checked.
1348 If both fail, None is returned.
1349
1350 Args:
1351 method_type: method type to initialize the cache for.
1352 Allowed values are: ``ip4`` | ``ip6`` | ``iface`` | ``default_iface``
1353 """
1354
1355 if str(METHOD_CACHE[method_type]) == method_name:
1356 return METHOD_CACHE[method_type]
1357
1358 for f_meth in FALLBACK_CACHE[method_type]:
1359 if str(f_meth) == method_name:
1360 return f_meth
1361
1362 return None
1363
1364
1365def _swap_method_fallback(method_type, swap_with):

Callers 1

get_mac_addressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected