1 #! /depot/sundry/plat/bin/python
3 # Note: you may have to edit the top line in this file.
5 # Usage: world addr1 [addr2 ...]
9 # This little script will take an Internet address of the form
10 # foobar@some.place.domain and will print out where in the world that
11 # message originated from. Its pretty dumb in that it just matches
12 # the `domain' part against a hard-coded list, which can probably
13 # change fairly quickly given the world's political fluidity.
19 print "No addresses provided.\nUsage:", prog
, "addr1 [addr2 ...]\n"
30 "org": "non-commercial",
31 "int": "international"
36 "ag": "Antigua and Barbuda",
57 "cz": "Czech Republic",
61 "do": "Dominican Republic",
69 "gb": "Great Britain",
84 "kn": "Saint Kitts and Nevis",
85 "kr": "Republic of Korea",
88 "li": "Liechtenstein",
100 "pg": "Papua New Guinea",
117 "tt": "Trinidad and Tobago",
118 "uk": "United Kingdom",
119 "us": "United States",
121 "vc": "Saint Vincent and the Grenadines",
123 "vi": "Virgin Islands",
125 "za": "South Africa",
132 rawaddr
= sys
.argv
[0]
135 components
= string
.splitfields(rawaddr
, ".")
136 addr
= components
[-1]
138 if nameorg
.has_key(addr
):
139 print addr
, "is from a USA", nameorg
[addr
], "organization"
140 elif country
.has_key(addr
):
141 print addr
, "originated from", country
[addr
]
143 print "I have no idea where", addr
, "came from!"