Created
May 9, 2024 12:18
-
-
Save d0now/cff0e0fdb020a5fd97685d3359a58c93 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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