MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _tab_complete

Method _tab_complete

tensorflow/python/debug/cli/curses_ui.py:1532–1568  ·  view source on GitHub ↗

Perform tab completion. Obtains tab completion candidates. If there are no candidates, return command_str and take no other actions. If there are candidates, display the candidates on screen and return command_str + (common prefix of the candidates). Args: command_str: (s

(self, command_str)

Source from the content-addressed store, hash-verified

1530 return None
1531
1532 def _tab_complete(self, command_str):
1533 """Perform tab completion.
1534
1535 Obtains tab completion candidates.
1536 If there are no candidates, return command_str and take no other actions.
1537 If there are candidates, display the candidates on screen and return
1538 command_str + (common prefix of the candidates).
1539
1540 Args:
1541 command_str: (str) The str in the command input textbox when Tab key is
1542 hit.
1543
1544 Returns:
1545 (str) Completed string. Could be the same as command_str if no completion
1546 candidate is available. If candidate(s) are available, return command_str
1547 appended by the common prefix of the candidates.
1548 """
1549
1550 context, prefix, except_last_word = self._analyze_tab_complete_input(
1551 command_str)
1552 candidates, common_prefix = self._tab_completion_registry.get_completions(
1553 context, prefix)
1554
1555 if candidates and len(candidates) > 1:
1556 self._display_candidates(candidates)
1557 else:
1558 # In the case of len(candidates) == 1, the single completion will be
1559 # entered to the textbox automatically. So there is no need to show any
1560 # candidates.
1561 self._display_candidates([])
1562
1563 if common_prefix:
1564 # Common prefix is not None and non-empty. The completed string will
1565 # incorporate the common prefix.
1566 return except_last_word + common_prefix
1567 else:
1568 return except_last_word + prefix
1569
1570 def _display_candidates(self, candidates):
1571 """Show candidates (e.g., tab-completion candidates) on multiple lines.

Callers 1

_ui_loopMethod · 0.95

Calls 3

_display_candidatesMethod · 0.95
get_completionsMethod · 0.80

Tested by

no test coverage detected