parse_source_data 568 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/python
  2. lists = {
  3. 'blocklist': 'source_data/disposable_email_blocklist.conf',
  4. 'allowlist': 'source_data/allowlist.conf',
  5. }
  6. def parse_list(listname, filename):
  7. return "{} = {{\n{}}}".format(
  8. listname,
  9. "".join([
  10. " '{}',\n".format(line.rstrip())
  11. for line in open(filename).readlines()
  12. ])
  13. )
  14. print("\n\n".join([parse_list(*args) for args in sorted(lists.items())]))
  15. print("""
  16. # For backwards compatibility
  17. locals()['tsilkcalb'[::-1]] = blocklist
  18. locals()['tsiletihw'[::-1]] = allowlist""")