|
82 | 82 | # Try to import readline, but allow failure for convenience in Windows unit testing
|
83 | 83 | # Note: If this actually fails, you should install readline on Linux or Mac or pyreadline on Windows
|
84 | 84 | try:
|
| 85 | + # noinspection PyUnresolvedReferences |
85 | 86 | import readline
|
86 | 87 | except ImportError:
|
87 | 88 | pass
|
@@ -479,6 +480,7 @@ class StubbornDict(dict):
|
479 | 480 |
|
480 | 481 | Create it with the stubbornDict(arg) factory function.
|
481 | 482 | """
|
| 483 | + # noinspection PyMethodOverriding |
482 | 484 | def update(self, arg):
|
483 | 485 | """Adds dictionary arg's key-values pairs in to dict
|
484 | 486 |
|
@@ -930,11 +932,11 @@ def precmd(self, statement):
|
930 | 932 | return statement
|
931 | 933 |
|
932 | 934 | def parseline(self, line):
|
933 |
| - """Parse the line into a command name and a string containing the arguments. |
934 |
| - |
| 935 | + """Parse the line into a command name and a string containing the arguments. |
| 936 | +
|
935 | 937 | Used for command tab completion. Returns a tuple containing (command, args, line).
|
936 | 938 | 'command' and 'args' may be None if the line couldn't be parsed.
|
937 |
| - |
| 939 | +
|
938 | 940 | :param line: str - line read by readline
|
939 | 941 | :return: (str, str, str) - tuple containing (command, args, line)
|
940 | 942 | """
|
@@ -1354,14 +1356,15 @@ def help_shell(self):
|
1354 | 1356 | Usage: shell cmd"""
|
1355 | 1357 | self.stdout.write("{}\n".format(help_str))
|
1356 | 1358 |
|
1357 |
| - def path_complete(self, text, line, begidx, endidx, dir_exe_only=False): |
| 1359 | + def path_complete(self, text, line, begidx, endidx, dir_exe_only=False, dir_only=False): |
1358 | 1360 | """Method called to complete an input line by local file system path completion.
|
1359 | 1361 |
|
1360 | 1362 | :param text: str - the string prefix we are attempting to match (all returned matches must begin with it)
|
1361 | 1363 | :param line: str - the current input line with leading whitespace removed
|
1362 | 1364 | :param begidx: int - the beginning indexe of the prefix text
|
1363 | 1365 | :param endidx: int - the ending index of the prefix text
|
1364 | 1366 | :param dir_exe_only: bool - only return directories and executables, not non-executable files
|
| 1367 | + :param dir_only: bool - only return directories |
1365 | 1368 | :return: List[str] - a list of possible tab completions
|
1366 | 1369 | """
|
1367 | 1370 | # Deal with cases like load command and @ key when path completion is immediately after a shortcut
|
@@ -1413,6 +1416,8 @@ def path_complete(self, text, line, begidx, endidx, dir_exe_only=False):
|
1413 | 1416 | # If we only want directories and executables, filter everything else out first
|
1414 | 1417 | if dir_exe_only:
|
1415 | 1418 | path_completions = [c for c in path_completions if os.path.isdir(c) or os.access(c, os.X_OK)]
|
| 1419 | + elif dir_only: |
| 1420 | + path_completions = [c for c in path_completions if os.path.isdir(c)] |
1416 | 1421 |
|
1417 | 1422 | # Get the basename of the paths
|
1418 | 1423 | completions = []
|
@@ -1446,7 +1451,7 @@ def _shell_command_complete(search_text):
|
1446 | 1451 | """Method called to complete an input line by environment PATH executable completion.
|
1447 | 1452 |
|
1448 | 1453 | :param search_text: str - the search text used to find a shell command
|
1449 |
| - :return: List[str] - a list of possible tab completions |
| 1454 | + :return: List[str] - a list of possible tab completions |
1450 | 1455 | """
|
1451 | 1456 |
|
1452 | 1457 | # Purposely don't match any executable containing wildcards
|
@@ -1478,7 +1483,7 @@ def _shell_command_complete(search_text):
|
1478 | 1483 | def complete_shell(self, text, line, begidx, endidx):
|
1479 | 1484 | """Handles tab completion of executable commands and local file system paths.
|
1480 | 1485 |
|
1481 |
| - :param text: str - the string prefix we are attempting to match (all returned matches must begin with it) |
| 1486 | + :param text: str - the string prefix we are attempting to match (all returned matches must begin with it) |
1482 | 1487 | :param line: str - the current input line with leading whitespace removed
|
1483 | 1488 | :param begidx: int - the beginning index of the prefix text
|
1484 | 1489 | :param endidx: int - the ending index of the prefix text
|
|
0 commit comments