Quoting¶
String and filename quoting support.
Constants¶
- kmd.quoting.QUOTE_CHARACTERS = '"\''¶
These characters may be used in pairs to quote substrings of the line.
- kmd.quoting.WORD_BREAK_CHARACTERS = ' \t\n"\'><;|&=(:'¶
These characters define word boundaries.
- kmd.quoting.FILENAME_QUOTE_CHARACTERS = '\\ \t\n"\'@><;|&=()#$`?*[!:{'¶
These characters are quoted when they occur in filenames.
- kmd.quoting.SLASHIFY_IN_QUOTES = '\\"$`\n'¶
These characters are backslash-quoted even between double quotes.
Extracted from Bash¶
- kmd.quoting.BASH_QUOTE_CHARACTERS = '\'"'¶
Quote characters used by Bash.
- kmd.quoting.BASH_COMPLETER_WORD_BREAK_CHARACTERS = ' \t\n"\'@><;|&=(:'¶
Word break characters used by Bash.
- kmd.quoting.BASH_NOHOSTNAME_WORD_BREAK_CHARACTERS = ' \t\n"\'><;|&=(:'¶
Word break characters used by Bash when hostname completion is off.
- kmd.quoting.BASH_FILENAME_QUOTE_CHARACTERS = '\\ \t\n"\'@><;|&=()#$`?*[!:{~'¶
Filename quote characters used by Bash.
- kmd.quoting.BASH_COMMAND_SEPARATORS = ';|&{(`'¶
Command separators used by Bash.
- kmd.quoting.BASH_WHITESPACE_CHARACTERS = ' \t\n'¶
Whitespace characters used by Bash.
- kmd.quoting.BASH_SLASHIFY_IN_QUOTES = '\\"$`\n'¶
Slashify characters used by Bash.
Functions¶
- kmd.quoting.backslash_quote(text, chars='')¶
Backslash-quote all
rl.completer.filename_quote_characters
intext
. Ifchars
is given, only characters inchars
are quoted.
- kmd.quoting.backslash_dequote(text, chars='')¶
Backslash-dequote all
rl.completer.filename_quote_characters
intext
. Ifchars
is given, only characters inchars
are dequoted.
- kmd.quoting.is_fully_quoted(text, chars='')¶
Return True if all
rl.completer.filename_quote_characters
intext
are backslash-quoted. Ifchars
is given, only characters inchars
are checked.
- kmd.quoting.char_is_quoted(text, index)¶
Return True if the character at
index
is quoted.
- kmd.quoting.quote_string(text, single_match=True, quote_char='')¶
Return a
quote_char
-quoted version oftext
. Ifsingle_match
is False, the quotes are not closed. The defaultquote_char
is the first character inrl.completer.quote_characters
.
- kmd.quoting.backslash_quote_string(text, single_match=True, quote_char='')¶
Return a backslash-quoted version of
text
. If aquote_char
is given, behave likequote_string()
.
- kmd.quoting.backslash_dequote_string(text, quote_char='')¶
Return a backslash-dequoted version of
text
. Ifquote_char
is the single-quote, backslash-dequoting is limited to single-quotes.
- kmd.quoting.quote_filename(text, single_match=True, quote_char='')¶
Return a
quote_char
-quoted version oftext
. Ifsingle_match
is False ortext
is a directory, the quotes are not closed. The defaultquote_char
is the first character inrl.completer.quote_characters
.
- kmd.quoting.backslash_quote_filename(text, single_match=True, quote_char='')¶
Return a backslash-quoted version of
text
. If aquote_char
is given, behave likequote_filename()
.
- kmd.quoting.backslash_dequote_filename(text, quote_char='')¶
Return a backslash-dequoted version of
text
. Ifquote_char
is the single-quote, backslash-dequoting is limited to single-quotes.