MCPcopy Index your code
hub / github.com/HelloZeroNet/ZeroNet / walk

Method walk

plugins/FilePack/FilePackPlugin.py:131–153  ·  view source on GitHub ↗
(self, inner_path, *args, **kwags)

Source from the content-addressed store, hash-verified

129 return archive
130
131 def walk(self, inner_path, *args, **kwags):
132 if ".zip" in inner_path or ".tar.gz" in inner_path:
133 match = re.match("^(.*\.(?:tar.gz|tar.bz2|zip))(.*)", inner_path)
134 archive_inner_path, path_within = match.groups()
135 archive = self.openArchive(archive_inner_path)
136 path_within = path_within.lstrip("/")
137
138 if archive_inner_path.endswith(".zip"):
139 namelist = [name for name in archive.namelist() if not name.endswith("/")]
140 else:
141 namelist = [item.name for item in archive.getmembers() if not item.isdir()]
142
143 namelist_relative = []
144 for name in namelist:
145 if not name.startswith(path_within):
146 continue
147 name_relative = name.replace(path_within, "", 1).rstrip("/")
148 namelist_relative.append(name_relative)
149
150 return namelist_relative
151
152 else:
153 return super(SiteStoragePlugin, self).walk(inner_path, *args, **kwags)
154
155 def list(self, inner_path, *args, **kwags):
156 if ".zip" in inner_path or ".tar.gz" in inner_path:

Callers 2

changeDbsMethod · 0.45
getFileListMethod · 0.45

Calls 1

openArchiveMethod · 0.95

Tested by

no test coverage detected