|
1 world -- Print mappings between country names and DNS country codes. |
|
2 |
|
3 Contact: Barry Warsaw |
|
4 Email: bwarsaw@python.org |
|
5 |
|
6 This script will take a list of Internet addresses and print out where in the |
|
7 world those addresses originate from, based on the top-level domain country |
|
8 code found in the address. Addresses can be in any of the following forms: |
|
9 |
|
10 xx -- just the country code or top-level domain identifier |
|
11 host.domain.xx -- any Internet host or network name |
|
12 somebody@where.xx -- an Internet email address |
|
13 |
|
14 If no match is found, the address is interpreted as a regular expression [*] |
|
15 and a reverse lookup is attempted. This script will search the country names |
|
16 and print a list of matching entries. You can force reverse mappings with the |
|
17 `-r' flag (see below). |
|
18 |
|
19 For example: |
|
20 |
|
21 %% world tz us |
|
22 tz originated from Tanzania, United Republic of |
|
23 us originated from United States |
|
24 |
|
25 %% world united |
|
26 united matches 6 countries: |
|
27 ae: United Arab Emirates |
|
28 uk: United Kingdom (common practice) |
|
29 um: United States Minor Outlying Islands |
|
30 us: United States |
|
31 tz: Tanzania, United Republic of |
|
32 gb: United Kingdom |
|
33 |
|
34 |
|
35 [*] Note that regular expressions must conform to Python 1.5's re.py module |
|
36 syntax. The comparison is done with the search() method. |
|
37 |
|
38 Country codes are maintained by the RIPE Network Coordination Centre, |
|
39 in coordination with the ISO 3166 Maintenance Agency at DIN Berlin. The |
|
40 authoritative source of counry code mappings is: |
|
41 |
|
42 <url:ftp://info.ripe.net/iso3166-countrycodes> |
|
43 |
|
44 The latest known change to this information was: |
|
45 |
|
46 Thu Aug 7 17:59:51 MET DST 1997 |
|
47 |
|
48 This script also knows about non-geographic top-level domains. |
|
49 |
|
50 Usage: world [-d] [-p file] [-o] [-h] addr [addr ...] |
|
51 |
|
52 --dump |
|
53 -d |
|
54 Print mapping of all top-level domains. |
|
55 |
|
56 --parse file |
|
57 -p file |
|
58 Parse an iso3166-countrycodes file extracting the two letter country |
|
59 code followed by the country name. Note that the three letter country |
|
60 codes and numbers, which are also provided in the standard format |
|
61 file, are ignored. |
|
62 |
|
63 --outputdict |
|
64 -o |
|
65 When used in conjunction with the `-p' option, output is in the form |
|
66 of a Python dictionary, and country names are normalized |
|
67 w.r.t. capitalization. This makes it appropriate for cutting and |
|
68 pasting back into this file. |
|
69 |
|
70 --reverse |
|
71 -r |
|
72 Force reverse lookup. In this mode the address can be any Python |
|
73 regular expression; this is matched against all country names and a |
|
74 list of matching mappings is printed. In normal mode (e.g. without |
|
75 this flag), reverse lookup is performed on addresses if no matching |
|
76 country code is found. |
|
77 |
|
78 -h |
|
79 --help |
|
80 Print this message. |
|
81 |
|
82 |
|
83 Local Variables: |
|
84 indent-tabs-mode: nil |
|
85 End: |