File: generate-mx-pickle.py

package info (click to toggle)
dnspython 2.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,448 kB
  • sloc: python: 34,885; sh: 7; makefile: 4
file content (19 lines) | stat: -rw-r--r-- 437 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import pickle
import sys

import dns.rdata
import dns.version

# Generate a pickled mx RR for the current dnspython version

mx = dns.rdata.from_text("in", "mx", "10 mx.example.")
filename = f"pickled-{dns.version.MAJOR}-{dns.version.MINOR}.pickle"
with open(filename, "wb") as f:
    pickle.dump(mx, f)
with open(filename, "rb") as f:
    mx2 = pickle.load(f)
if mx == mx2:
    print("ok")
else:
    print("DIFFERENT!")
    sys.exit(1)