xref: /aosp_15_r20/external/brotli/scripts/dictionary/step-01-download-rfc.py (revision f4ee7fba7774faf2a30f13154332c0a06550dbc4)
1*f4ee7fbaSAndroid Build Coastguard Worker# Step 01 - download RFC7932.
2*f4ee7fbaSAndroid Build Coastguard Worker#
3*f4ee7fbaSAndroid Build Coastguard Worker# RFC is the ultimate source for brotli format and constants, including
4*f4ee7fbaSAndroid Build Coastguard Worker# static dictionary.
5*f4ee7fbaSAndroid Build Coastguard Worker
6*f4ee7fbaSAndroid Build Coastguard Workerimport urllib2
7*f4ee7fbaSAndroid Build Coastguard Worker
8*f4ee7fbaSAndroid Build Coastguard Workerresponse = urllib2.urlopen('https://tools.ietf.org/rfc/rfc7932.txt')
9*f4ee7fbaSAndroid Build Coastguard Worker
10*f4ee7fbaSAndroid Build Coastguard Workertext = response.read()
11*f4ee7fbaSAndroid Build Coastguard Workerpath = "rfc7932.txt"
12*f4ee7fbaSAndroid Build Coastguard Worker
13*f4ee7fbaSAndroid Build Coastguard Workerwith open(path, "w") as rfc:
14*f4ee7fbaSAndroid Build Coastguard Worker  rfc.write(text)
15*f4ee7fbaSAndroid Build Coastguard Worker
16*f4ee7fbaSAndroid Build Coastguard Workerprint("Downloaded and saved " + str(len(text)) + " bytes to " + path)
17