Download tier2_thunderbird/_backup/check_backup.py from tanmaydeo/AutonexAI: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/datasets/tanmaydeo/AutonexAI/resolve/main/tier2_thunderbird/_backup/check_backup.py
- Command line
-
hf download hf://datasets/tanmaydeo/AutonexAI/tier2_thunderbird/_backup/check_backup.py
-
curl -L -o check_backup.py https://huggingface.co/datasets/tanmaydeo/AutonexAI/resolve/main/tier2_thunderbird/_backup/check_backup.py
1.32 kB
| #!/usr/bin/env python3 | |
| """Verify a folder was backed up as SEPARATE .eml files. | |
| Usage: check_backup.py <dir> <subjectA||subjectB||...>. Prints "Backup OK!" only | |
| if the dir holds >= N distinct .eml files, each parseable as one message, that | |
| collectively cover every expected subject (one subject per file). A single | |
| combined export, a non-.eml file, or a no-op fails -> not a false positive; the | |
| filename itself is not constrained (agent-independent).""" | |
| import sys, os, glob, email | |
| def main(): | |
| if len(sys.argv) < 3: | |
| print("Backup incomplete!"); return | |
| d, subs = sys.argv[1], [s for s in sys.argv[2].split("||") if s] | |
| emls = glob.glob(os.path.join(d, "*.eml")) | |
| if len(emls) < len(subs): | |
| print("Backup incomplete! ({} eml, need {})".format(len(emls), len(subs))); return | |
| remaining, used = list(subs), set() | |
| for p in emls: | |
| try: | |
| subj = email.message_from_file( | |
| open(p, encoding="utf-8", errors="replace")).get("Subject") or "" | |
| except Exception: | |
| continue | |
| for s in list(remaining): | |
| if s.lower() in subj.lower() and p not in used: | |
| remaining.remove(s); used.add(p); break | |
| print("Backup OK! ({} eml files)".format(len(emls)) if not remaining | |
| else "Backup incomplete!") | |
| main() | |