Skip to content

Commit

Permalink
Implement cat() for multifile for github (#1620)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindurant committed Jun 4, 2024
1 parent 447c27d commit 91ead5f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions fsspec/implementations/github.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import requests

import fsspec

from ..spec import AbstractFileSystem
from ..utils import infer_storage_options
from .memory import MemoryFile
Expand Down Expand Up @@ -225,3 +227,13 @@ def _open(
raise FileNotFoundError(path)
r.raise_for_status()
return MemoryFile(None, None, r.content)

def cat(self, path, recursive=False, on_error="raise", **kwargs):
paths = self.expand_path(path, recursive=recursive)
urls = [
self.rurl.format(org=self.org, repo=self.repo, path=u, sha=self.root)
for u, sh in paths
]
fs = fsspec.filesystem("http")
data = fs.cat(urls, on_error="return")
return {u: v for ((k, v), u) in zip(data.items(), urls)}

0 comments on commit 91ead5f

Please sign in to comment.