/Tools/world/README

http://unladen-swallow.googlecode.com/ · #! · 85 lines · 64 code · 21 blank · 0 comment · 0 complexity · 3166e771a5c2c0a26442f4a3f5df73ce MD5 · raw file

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