|
33 | 33 | import cmd
|
34 | 34 | import collections
|
35 | 35 | from colorama import Fore
|
36 |
| -import copy |
37 | 36 | import glob
|
38 | 37 | import os
|
39 | 38 | import platform
|
@@ -498,10 +497,11 @@ def __init__(self, completekey='tab', stdin=None, stdout=None, persistent_histor
|
498 | 497 | # An optional header that prints above the tab-completion suggestions
|
499 | 498 | self.completion_header = ''
|
500 | 499 |
|
501 |
| - # If the tab-completion suggestions should be displayed in a way that is different than the actual match values, |
502 |
| - # then place those results in this list. The full matches still must be returned from your completer function. |
503 |
| - # For an example, look at path_complete() which uses this to show only the basename of paths as the |
504 |
| - # suggestions. delimiter_complete() also populates this list. |
| 500 | + # Use this list if you are completing strings that contain a common delimiter and you only want to |
| 501 | + # display the final portion of the matches as the tab-completion suggestions. The full matches |
| 502 | + # still must be returned from your completer function. For an example, look at path_complete() |
| 503 | + # which uses this to show only the basename of paths as the suggestions. delimiter_complete() also |
| 504 | + # populates this list. |
505 | 505 | self.display_matches = []
|
506 | 506 |
|
507 | 507 | # Used by functions like path_complete() and delimiter_complete() to properly
|
@@ -692,6 +692,7 @@ def tokens_for_completion(self, line, begidx, endidx):
|
692 | 692 | On Failure
|
693 | 693 | Both items are None
|
694 | 694 | """
|
| 695 | + import copy |
695 | 696 | unclosed_quote = ''
|
696 | 697 | quotes_to_try = copy.copy(constants.QUOTES)
|
697 | 698 |
|
@@ -1330,7 +1331,7 @@ def complete(self, text, state):
|
1330 | 1331 | # from text and update the indexes. This only applies if we are at the the beginning of the line.
|
1331 | 1332 | shortcut_to_restore = ''
|
1332 | 1333 | if begidx == 0:
|
1333 |
| - for (shortcut, expansion) in self.shortcuts: |
| 1334 | + for (shortcut, _) in self.shortcuts: |
1334 | 1335 | if text.startswith(shortcut):
|
1335 | 1336 | # Save the shortcut to restore later
|
1336 | 1337 | shortcut_to_restore = shortcut
|
@@ -1439,6 +1440,7 @@ def complete(self, text, state):
|
1439 | 1440 | # Since self.display_matches is empty, set it to self.completion_matches
|
1440 | 1441 | # before we alter them. That way the suggestions will reflect how we parsed
|
1441 | 1442 | # the token being completed and not how readline did.
|
| 1443 | + import copy |
1442 | 1444 | self.display_matches = copy.copy(self.completion_matches)
|
1443 | 1445 |
|
1444 | 1446 | # Check if we need to add an opening quote
|
@@ -1855,7 +1857,7 @@ def _redirect_output(self, statement):
|
1855 | 1857 | if statement.output == constants.REDIRECTION_APPEND:
|
1856 | 1858 | mode = 'a'
|
1857 | 1859 | try:
|
1858 |
| - sys.stdout = self.stdout = open(os.path.expanduser(statement.output_to), mode) |
| 1860 | + sys.stdout = self.stdout = open(statement.output_to, mode) |
1859 | 1861 | except OSError as ex:
|
1860 | 1862 | self.perror('Not Redirecting because - {}'.format(ex), traceback_war=False)
|
1861 | 1863 | self.redirecting = False
|
@@ -2384,7 +2386,7 @@ def select(self, opts, prompt='Your choice? '):
|
2384 | 2386 | fulloptions.append((opt[0], opt[1]))
|
2385 | 2387 | except IndexError:
|
2386 | 2388 | fulloptions.append((opt[0], opt[0]))
|
2387 |
| - for (idx, (value, text)) in enumerate(fulloptions): |
| 2389 | + for (idx, (_, text)) in enumerate(fulloptions): |
2388 | 2390 | self.poutput(' %2d. %s\n' % (idx + 1, text))
|
2389 | 2391 | while True:
|
2390 | 2392 | response = input(prompt)
|
|
0 commit comments