docs/tutorial/testlib/arguments_printer.py
author Pulkit Goyal <pulkit@yandex-team.ru>
Fri, 12 Oct 2018 02:12:23 +0300
changeset 4158 5dd45784a8e0
parent 3376 aad37ffd7d58
permissions -rw-r--r--
rewind: alias the command to undo This is a step in unifiying rewind and undo and not talk about them as different commands or concepts. If there exists rewind command, that should be an alias of undo and the vice versa. The exact implmentation detail and how the command works etc. is a different thing but there should be just one command.

import sys

formatted_args = []

UNSAFE_CHARACTERS = [" ", "!", "\"", "#", "$", "&", "'", "(", ")", "*", ",", ";", "<", ">", "?", "[", "\\", "]", "^", "`", "{", "|", "}", ":", "~", "/"]


def find_unsafe(arg):
    for unsafe in UNSAFE_CHARACTERS:
        if unsafe in arg:
            return True

    return False


for arg in sys.argv[1:]:
    if find_unsafe(arg):
        formatted_args.append('"%s"' % arg)
    else:
        formatted_args.append(arg)

print("$ " + " ".join(formatted_args))