Beispiel #1
0
def test_shquote():
    WVPASSEQ(qst("""  this is    basic \t\n\r text  """),
             ['this', 'is', 'basic', 'text'])
    WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', 'help', 'yelp'])
    WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", '\\"\''])

    WVPASSEQ(shquote.quotesplit('  this is "unfinished'), [(2, 'this'),
                                                           (7, 'is'),
                                                           (10, 'unfinished')])

    WVPASSEQ(shquote.quotesplit('"silly"\'will'), [(0, 'silly'), (7, 'will')])

    WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'), ('"', 'goat'))
    WVPASSEQ(shquote.unfinished_word("'x"), ("'", 'x'))
    WVPASSEQ(shquote.unfinished_word("abra cadabra "), (None, ''))
    WVPASSEQ(shquote.unfinished_word("abra cadabra"), (None, 'cadabra'))

    (qtype, word) = shquote.unfinished_word("this is /usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), "al")
    (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), "al'")
    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), "al\"")
    (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False), "al")
    (qtype, word) = shquote.unfinished_word("this is \\ hammer\\ \"")
    WVPASSEQ(word, ' hammer "')
    WVPASSEQ(shquote.what_to_add(qtype, word, " hammer \"time\"", True),
             "time\\\"")

    WVPASSEQ(shquote.quotify_list(['a', '', '"word"', "'third'", "'", "x y"]),
             "a '' '\"word\"' \"'third'\" \"'\" 'x y'")
Beispiel #2
0
def test_shquote():
    with no_lingering_errors():
        WVPASSEQ(qst("""  this is    basic \t\n\r text  """), ["this", "is", "basic", "text"])
        WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', "help", "yelp"])
        WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", "\\\"'"])

        WVPASSEQ(shquote.quotesplit('  this is "unfinished'), [(2, "this"), (7, "is"), (10, "unfinished")])

        WVPASSEQ(shquote.quotesplit('"silly"\'will'), [(0, "silly"), (7, "will")])

        WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'), ('"', "goat"))
        WVPASSEQ(shquote.unfinished_word("'x"), ("'", "x"))
        WVPASSEQ(shquote.unfinished_word("abra cadabra "), (None, ""))
        WVPASSEQ(shquote.unfinished_word("abra cadabra"), (None, "cadabra"))

        (qtype, word) = shquote.unfinished_word("this is /usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), "al")
        (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), "al'")
        (qtype, word) = shquote.unfinished_word('this is "/usr/loc')
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True), 'al"')
        (qtype, word) = shquote.unfinished_word('this is "/usr/loc')
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False), "al")
        (qtype, word) = shquote.unfinished_word('this is \\ hammer\\ "')
        WVPASSEQ(word, ' hammer "')
        WVPASSEQ(shquote.what_to_add(qtype, word, ' hammer "time"', True), 'time\\"')

        WVPASSEQ(
            shquote.quotify_list(["a", "", '"word"', "'third'", "'", "x y"]), "a '' '\"word\"' \"'third'\" \"'\" 'x y'"
        )
Beispiel #3
0
def _completer_get_subs(line):
    (qtype, lastword) = shquote.unfinished_word(line)
    (dir,name) = os.path.split(lastword)
    #log('\ncompleter: %r %r %r\n' % (qtype, lastword, text))
    n = pwd.resolve(dir)
    subs = list(filter(lambda x: x.name.startswith(name),
                       n.subs()))
    return (dir, name, qtype, lastword, subs)
Beispiel #4
0
def _completer_get_subs(line):
    (qtype, lastword) = shquote.unfinished_word(line)
    (dir, name) = os.path.split(lastword)
    #log('\ncompleter: %r %r %r\n' % (qtype, lastword, text))
    try:
        n = pwd.resolve(dir)
        subs = list(filter(lambda x: x.name.startswith(name), n.subs()))
    except vfs.NoSuchFile, e:
        subs = []
Beispiel #5
0
def _completer_get_subs(line):
    (qtype, lastword) = shquote.unfinished_word(line)
    (dir, name) = os.path.split(lastword)
    # log('\ncompleter: %r %r %r\n' % (qtype, lastword, text))
    try:
        n = pwd.resolve(dir)
        subs = list(filter(lambda x: x.name.startswith(name), n.subs()))
    except vfs.NoSuchFile, e:
        subs = []
Beispiel #6
0
def _completer_get_subs(repo, line):
    (qtype, lastword) = shquote.unfinished_word(line)
    dir, name = os.path.split(lastword)
    dir_path = vfs.resolve(repo, dir or b'/')
    _, dir_item = dir_path[-1]
    if not dir_item:
        subs = tuple()
    else:
        subs = tuple(dir_path + (entry, )
                     for entry in vfs.contents(repo, dir_item)
                     if (entry[0] != b'.' and entry[0].startswith(name)))
    return qtype, lastword, subs
Beispiel #7
0
def _completer_get_subs(repo, line):
    (qtype, lastword) = shquote.unfinished_word(line)
    (dir,name) = os.path.split(lastword)
    dir_path = vfs.resolve(repo, dir or '/')
    _, dir_item = dir_path[-1]
    if not dir_item:
        subs = tuple()
    else:
        subs = tuple(dir_path + (entry,)
                     for entry in vfs.contents(repo, dir_item)
                     if (entry[0] != '.' and entry[0].startswith(name)))
    return dir, name, qtype, lastword, subs
Beispiel #8
0
def test_shquote():
    with no_lingering_errors():
        WVPASSEQ(qst("""  this is    basic \t\n\r text  """),
                 ['this', 'is', 'basic', 'text'])
        WVPASSEQ(qst(r""" \"x\" "help" 'yelp' """), ['"x"', 'help', 'yelp'])
        WVPASSEQ(qst(r""" "'\"\"'" '\"\'' """), ["'\"\"'", '\\"\''])

        WVPASSEQ(shquote.quotesplit('  this is "unfinished'),
                 [(2,'this'), (7,'is'), (10,'unfinished')])

        WVPASSEQ(shquote.quotesplit('"silly"\'will'),
                 [(0,'silly'), (7,'will')])

        WVPASSEQ(shquote.unfinished_word('this is a "billy" "goat'),
                 ('"', 'goat'))
        WVPASSEQ(shquote.unfinished_word("'x"),
                 ("'", 'x'))
        WVPASSEQ(shquote.unfinished_word("abra cadabra "),
                 (None, ''))
        WVPASSEQ(shquote.unfinished_word("abra cadabra"),
                 (None, 'cadabra'))

        (qtype, word) = shquote.unfinished_word("this is /usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
                 "al")
        (qtype, word) = shquote.unfinished_word("this is '/usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
                 "al'")
        (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", True),
                 "al\"")
        (qtype, word) = shquote.unfinished_word("this is \"/usr/loc")
        WVPASSEQ(shquote.what_to_add(qtype, word, "/usr/local", False),
                 "al")
        (qtype, word) = shquote.unfinished_word("this is \\ hammer\\ \"")
        WVPASSEQ(word, ' hammer "')
        WVPASSEQ(shquote.what_to_add(qtype, word, " hammer \"time\"", True),
                 "time\\\"")

        WVPASSEQ(shquote.quotify_list(['a', '', '"word"', "'third'", "'", "x y"]),
                 "a '' '\"word\"' \"'third'\" \"'\" 'x y'")
Beispiel #9
0
def test_shquote():
    WVPASSEQ(qst(b"""  this is    basic \t\n\r text  """),
             [b'this', b'is', b'basic', b'text'])
    WVPASSEQ(qst(br""" \"x\" "help" 'yelp' """), [b'"x"', b'help', b'yelp'])
    WVPASSEQ(qst(br""" "'\"\"'" '\"\'' """), [b"'\"\"'", b'\\"\''])

    WVPASSEQ(shquote.quotesplit(b'  this is "unfinished'),
             [(2, b'this'), (7, b'is'), (10, b'unfinished')])

    WVPASSEQ(shquote.quotesplit(b'"silly"\'will'),
             [(0, b'silly'), (7, b'will')])

    WVPASSEQ(shquote.unfinished_word(b'this is a "billy" "goat'),
             (b'"', b'goat'))
    WVPASSEQ(shquote.unfinished_word(b"'x"),
             (b"'", b'x'))
    WVPASSEQ(shquote.unfinished_word(b"abra cadabra "),
             (None, b''))
    WVPASSEQ(shquote.unfinished_word(b"abra cadabra"),
             (None, b'cadabra'))

    qtype, word = shquote.unfinished_word(b"this is /usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, b"/usr/local", True),
             b"al")
    qtype, word = shquote.unfinished_word(b"this is '/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, b"/usr/local", True),
             b"al'")
    qtype, word = shquote.unfinished_word(b"this is \"/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, b"/usr/local", True),
             b"al\"")
    qtype, word = shquote.unfinished_word(b"this is \"/usr/loc")
    WVPASSEQ(shquote.what_to_add(qtype, word, b"/usr/local", False),
             b"al")
    qtype, word = shquote.unfinished_word(b"this is \\ hammer\\ \"")
    WVPASSEQ(word, b' hammer "')
    WVPASSEQ(shquote.what_to_add(qtype, word, b" hammer \"time\"", True),
             b"time\\\"")

    WVPASSEQ(shquote.quotify_list([b'a', b'', b'"word"', b"'third'", b"'",
                                   b"x y"]),
             b"a '' '\"word\"' \"'third'\" \"'\" 'x y'")