Skip to content

Instantly share code, notes, and snippets.

@d0now
Created May 9, 2024 12:18
Show Gist options
  • Save d0now/cff0e0fdb020a5fd97685d3359a58c93 to your computer and use it in GitHub Desktop.
Save d0now/cff0e0fdb020a5fd97685d3359a58c93 to your computer and use it in GitHub Desktop.
from glob import glob
from pathlib import Path
from zipfile import ZipFile
def main(args):
with ZipFile(str(args.out), 'w') as zip:
for _f in glob(f"{args.dir}/**", recursive=True):
file = Path(_f)
if file.is_file():
magic = file.open('rb').read(4)
if magic.startswith(b"\x7fELF"):
zip.write(str(file))
if __name__ == "__main__":
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument("-o", "--out", type=Path, required=True)
parser.add_argument("-d", "--dir", type=Path, default=Path("."))
args = parser.parse_args()
main(args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment