Parse MP modules regardless of language
@@ -344,10 +344,18 @@ class MicroPythonProxy(BackendProxy):
assert self.idle
out, err = self._execute_and_get_response("help('modules')")
assert err == b"", "Error was: %r" % err
+ modules_str_lines = out.decode("utf-8").strip().splitlines()
+
+ last_line = modules_str_lines[-1].strip()
+ if last_line.count(" ") > 0 and " " not in last_line and "\t" not in last_line:
+ # probably something like "plus any modules on the filesystem"
+ # (can be in different languages)
+ modules_str_lines = modules_str_lines[:-1]
+
modules_str = (
- out.decode("utf-8")
- .replace("Plus any modules on the filesystem", "")
+ " ".join(modules_str_lines)
.replace("/__init__", "")
+ .replace("__main__", "")
.replace("/", ".")
)
return modules_str.split()
