Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
_view_zip.py23 linesDownload Raw Back to contentviews
1import io2import zipfile3 4from mitmproxy.contentviews._api import Contentview5from mitmproxy.contentviews._api import Metadata6from mitmproxy.contentviews._utils import yaml_dumps7 8 9class ZipContentview(Contentview):10    name = "ZIP Archive"11    syntax_highlight = "yaml"12 13    def prettify(self, data: bytes, metadata: Metadata) -> str:14        with zipfile.ZipFile(io.BytesIO(data), "r") as zip_file:15            filenames = [info.filename for info in zip_file.infolist()]16            return yaml_dumps(filenames) if filenames else "(empty zip file)"17 18    def render_priority(self, data: bytes, metadata: Metadata) -> float:19        return 1.0 if data and metadata.content_type == "application/zip" else 020 21 22zip = ZipContentview()23 
codekingpro/portable-devtools · Team Ai