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 in text. If chars is given, only characters in chars are quoted.

kmd.quoting.backslash_dequote(text, chars='')

Backslash-dequote all rl.completer.filename_quote_characters in text. If chars is given, only characters in chars are dequoted.

kmd.quoting.is_fully_quoted(text, chars='')

Return True if all rl.completer.filename_quote_characters in text are backslash-quoted. If chars is given, only characters in chars 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 of text. If single_match is False, the quotes are not closed. The default quote_char is the first character in rl.completer.quote_characters.

kmd.quoting.backslash_quote_string(text, single_match=True, quote_char='')

Return a backslash-quoted version of text. If a quote_char is given, behave like quote_string().

kmd.quoting.backslash_dequote_string(text, quote_char='')

Return a backslash-dequoted version of text. If quote_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 of text. If single_match is False or text is a directory, the quotes are not closed. The default quote_char is the first character in rl.completer.quote_characters.

kmd.quoting.backslash_quote_filename(text, single_match=True, quote_char='')

Return a backslash-quoted version of text. If a quote_char is given, behave like quote_filename().

kmd.quoting.backslash_dequote_filename(text, quote_char='')

Return a backslash-dequoted version of text. If quote_char is the single-quote, backslash-dequoting is limited to single-quotes.