MCPcopy Index your code
hub / github.com/pyinvoke/invoke / _transform_lexicon

Method _transform_lexicon

invoke/collection.py:495–510  ·  view source on GitHub ↗

Take a Lexicon and apply `.transform` to its keys and aliases. :returns: A new Lexicon.

(self, old: Lexicon)

Source from the content-addressed store, hash-verified

493 return "".join(replaced)
494
495 def _transform_lexicon(self, old: Lexicon) -> Lexicon:
496 """
497 Take a Lexicon and apply `.transform` to its keys and aliases.
498
499 :returns: A new Lexicon.
500 """
501 new = Lexicon()
502 # Lexicons exhibit only their real keys in most places, so this will
503 # only grab those, not aliases.
504 for key, value in old.items():
505 # Deepcopy the value so we're not just copying a reference
506 new[self.transform(key)] = copy.deepcopy(value)
507 # Also copy all aliases, which are string-to-string key mappings
508 for key, value in old.aliases.items():
509 new.alias(from_=self.transform(key), to=self.transform(value))
510 return new
511
512 @property
513 def task_names(self) -> Dict[str, List[str]]:

Callers 1

from_moduleMethod · 0.80

Calls 1

transformMethod · 0.95

Tested by

no test coverage detected