Skip to content

Instantly share code, notes, and snippets.

@Lacoste
Forked from mnordhoff/public_suffix_list.py
Created June 7, 2020 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Lacoste/2f0d24ecfe5867607625a388b6a30ec0 to your computer and use it in GitHub Desktop.
Save Lacoste/2f0d24ecfe5867607625a388b6a30ec0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
import idna
def main():
for line in sys.stdin:
line = line.rstrip()
if not line:
continue
if line.startswith(('!', '//')):
continue
if line.startswith('*.'):
line = line[len('*.'):]
print idna.encode(line.decode('utf-8'))
if __name__ == '__main__':
main()
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import sys
def _key(line):
split = line.split('.')
split.reverse()
return split
def main():
sys.stdout.writelines(sorted(set(sys.stdin), key=_key))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment