MCPcopy Create free account
hub / github.com/Keeper-Security/Commander / escape_string

Function escape_string

keepercommander/autocomplete.py:78–96  ·  view source on GitHub ↗

Replace special characters in string, for interactive shell quoting, as part of tab-completion.

(have_initial_double_quote, string)

Source from the content-addressed store, hash-verified

76
77
78def escape_string(have_initial_double_quote, string):
79 """Replace special characters in string, for interactive shell quoting, as part of tab-completion."""
80 if have_initial_double_quote:
81 tuple_ = (
82 ('\\', '\\\\'),
83 ('"', r'\"'),
84 ('/', '//'),
85 )
86 else:
87 tuple_ = (
88 ('\\', '\\\\'),
89 ("'", r"\'"),
90 (' ', r'\ '),
91 ('"', r'\"'),
92 ('/', '//'),
93 )
94 for from_str, to_str in tuple_:
95 string = string.replace(from_str, to_str)
96 return string
97
98
99class CommandCompleter(Completer):

Callers 1

get_completionsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected