MCPcopy Create free account
hub / github.com/dot-agent/nextpy / _reverse_mapping

Function _reverse_mapping

nextpy/__init__.py:300–318  ·  view source on GitHub ↗

Reverse the mapping used to lazy loading, and check for conflicting name. Args: mapping: The mapping to reverse. Returns: The reversed mapping.

(mapping: dict[str, list])

Source from the content-addressed store, hash-verified

298
299
300def _reverse_mapping(mapping: dict[str, list]) -> dict[str, str]:
301 """Reverse the mapping used to lazy loading, and check for conflicting name.
302
303 Args:
304 mapping: The mapping to reverse.
305
306 Returns:
307 The reversed mapping.
308 """
309 reversed_mapping = {}
310 for key, values in mapping.items():
311 for value in values:
312 if value not in reversed_mapping:
313 reversed_mapping[value] = key
314 else:
315 console.warn(
316 f"Key {value} is present multiple times in the imports _MAPPING: {key} / {reversed_mapping[value]}"
317 )
318 return reversed_mapping
319
320
321# _MAPPING = {value: key for key, values in _MAPPING.items() for value in values}

Callers 1

__init__.pyFile · 0.85

Calls 1

itemsMethod · 0.80

Tested by

no test coverage detected