MCPcopy
hub / github.com/HelloZeroNet/ZeroNet / read

Method read

plugins/FilePack/FilePackPlugin.py:182–195  ·  view source on GitHub ↗
(self, inner_path, mode="rb")

Source from the content-addressed store, hash-verified

180 return super(SiteStoragePlugin, self).list(inner_path, *args, **kwags)
181
182 def read(self, inner_path, mode="rb"):
183 if ".zip/" in inner_path or ".tar.gz/" in inner_path:
184 match = re.match("^(.*\.(?:tar.gz|tar.bz2|zip))(.*)", inner_path)
185 archive_inner_path, path_within = match.groups()
186 archive = self.openArchive(archive_inner_path)
187 path_within = path_within.lstrip("/")
188
189 if archive_inner_path.endswith(".zip"):
190 return archive.open(path_within).read()
191 else:
192 return archive.extractfile(path_within).read()
193
194 else:
195 return super(SiteStoragePlugin, self).read(inner_path, mode)
196

Callers 1

streamFileMethod · 0.45

Calls 2

openArchiveMethod · 0.95
openMethod · 0.80

Tested by

no test coverage detected