I’m stuck on Stage #ue6.
Here are my logs:
[tester::#ZV2] ✓ Prompt line matches "$ wc grape-"
[tester::#ZV2] Pressed "<TAB>" (expecting autocomplete to "wc grape-90.txt" followed by a space)
[your-program] $ wc grape-grape-90.txt
[tester::#ZV2] ^ Line does not match expected value.
[tester::#ZV2] Expected: "$ wc grape-90.txt "
[tester::#ZV2] Received: "$ wc grape-grape-90.txt "
Locally when I run it, It is working correctly.
Python Completer code:
builtin=["exit", "echo", "type", "pwd","cd"]
autocomplete_list=builtin.copy()
for path in os.environ.get("PATH", "").split(os.pathsep):
if os.path.exists(path):
autocomplete_list.extend(os.listdir(path))
def completer(text,state):
buffer = readline.get_line_buffer()
last_word = buffer.split()[-1] if buffer else ""
prev_path = Path(last_word)
if not prev_path.is_dir():
prev_path = Path()
if not text:
options=([cmd for cmd in os.listdir(prev_path)])
else:
if '/' not in text and '\\' not in text:
options = [cmd for cmd in autocomplete_list if cmd.startswith(text)]
options.extend([cmd for cmd in os.listdir() if cmd.startswith(text)])
else:
path = prev_path/Path(text)
prefix = ".\\" if not path.is_absolute else ""
if path.is_dir():
options = [prefix+str(path/cmd) for cmd in os.listdir(path)]
else:
path_dir = path.parent.absolute()
path_text = path.name
options = [cmd for cmd in os.listdir(path_dir) if cmd.startswith(path_text)]
if state < len(options):
option = Path(options[state])
if option.is_dir():
return str(option)+"/"
return options[state]+" "
return None
What am I here?