Skip to content

Commit 91ead5f

Browse files
authored
Implement cat() for multifile for github (#1620)
1 parent 447c27d commit 91ead5f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

fsspec/implementations/github.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import requests
22

3+
import fsspec
4+
35
from ..spec import AbstractFileSystem
46
from ..utils import infer_storage_options
57
from .memory import MemoryFile
@@ -225,3 +227,13 @@ def _open(
225227
raise FileNotFoundError(path)
226228
r.raise_for_status()
227229
return MemoryFile(None, None, r.content)
230+
231+
def cat(self, path, recursive=False, on_error="raise", **kwargs):
232+
paths = self.expand_path(path, recursive=recursive)
233+
urls = [
234+
self.rurl.format(org=self.org, repo=self.repo, path=u, sha=self.root)
235+
for u, sh in paths
236+
]
237+
fs = fsspec.filesystem("http")
238+
data = fs.cat(urls, on_error="return")
239+
return {u: v for ((k, v), u) in zip(data.items(), urls)}

0 commit comments

Comments
 (0)