• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2import sys
3import urllib.request, urllib.error, urllib.parse
4import codecs
5
6def main():
7    encodings = []
8    f = urllib.request.urlopen(sys.argv[1])
9    for line in f:
10        if line.startswith("Name: ") or line.startswith("Alias: "):
11            enc = line.split()[1]
12            try:
13                codecs.lookup(enc)
14                if enc.lower not in encodings:
15                    encodings.append(enc.lower())
16            except LookupError:
17                pass
18    sys.stdout.write("encodings = frozenset((\n")
19    for enc in encodings:
20        sys.stdout.write('    "%s",\n'%enc)
21    sys.stdout.write('    ))')
22
23if __name__ == "__main__":
24    main()