view python/tld.py @ 646:0e15d5aa78a2

add mount usb disk stub
author Jeff Hammel <k0scist@gmail.com>
date Tue, 11 Mar 2014 23:00:50 -0700
parents c7edd15d7f8b
children 0bc7c1a5eb83
line wrap: on
line source

#!/usr/bin/env python

URL = 'http://www.palosverdes.com/jesse/irc/country.txt'

import urllib2

def codes():
  f = urllib2.urlopen(URL)
  codes = {}
  for line in f.readlines():
    line = line.strip()
    if not line:
      continue
    key, value = line.split(None, 1)
    codes[key.lower()] = value
  return codes
codes = codes()

def get(code):
  code = code.lstrip('.').lower()
  return codes.get(code)

if __name__ == '__main__':
  import sys
  for arg in sys.argv[1:]:
    print '%s: %s' % (arg, get(arg))