MCPcopy
hub / github.com/marimo-team/marimo / list_files

Method list_files

marimo/_server/files/os_file_system.py:72–106  ·  view source on GitHub ↗
(self, path: str)

Source from the content-addressed store, hash-verified

70 return os.getcwd()
71
72 def list_files(self, path: str) -> list[FileInfo]:
73 files: list[FileInfo] = []
74 folders: list[FileInfo] = []
75 try:
76 with os.scandir(path) as it:
77 for entry in it:
78 if entry.name in LIST_IGNORE_LIST:
79 continue
80 try:
81 is_directory = entry.is_dir()
82 entry_stat = entry.stat()
83 except OSError:
84 # do not include files that fail to read
85 # (e.g. recursive/broken symlinks)
86 continue
87
88 info = FileInfo(
89 id=entry.path,
90 path=entry.path,
91 name=entry.name,
92 is_directory=is_directory,
93 is_marimo_file=not is_directory
94 and self._is_marimo_file(entry.path),
95 last_modified=entry_stat.st_mtime,
96 )
97 if is_directory:
98 folders.append(info)
99 else:
100 files.append(info)
101 except OSError:
102 pass
103
104 return sorted(folders, key=natural_sort_file) + sorted(
105 files, key=natural_sort_file
106 )
107
108 def _get_file_info(self, path: str) -> FileInfo:
109 stat = os.stat(path)

Callers

nothing calls this directly

Calls 5

_is_marimo_fileMethod · 0.95
FileInfoClass · 0.90
is_dirMethod · 0.80
statMethod · 0.80
appendMethod · 0.45

Tested by

no test coverage detected