[Python-checkins] python/dist/src/Tools/world world,3.13,3.14

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Fri, 07 Jun 2002 07:47:22 -0700


Update of /cvsroot/python/python/dist/src/Tools/world
In directory usw-pr-cvs1:/tmp/cvs-serv27392/world

Modified Files:
	world 
Log Message:
Apply diff2.txt from SF patch http://www.python.org/sf/565471

This patch replaces string module functions with string
methods in the Tools/world/world scripts.

It also updates two outdated URLs and the countrycodes
dictionary.

It fixes a bug where result of string.find() was checked 
for truth instead of compared with -1.

It also replaces <> with != in two spots.


Index: world
===================================================================
RCS file: /cvsroot/python/python/dist/src/Tools/world/world,v
retrieving revision 3.13
retrieving revision 3.14
diff -C2 -d -r3.13 -r3.14
*** world	26 May 1999 04:02:18 -0000	3.13
--- world	7 Jun 2002 14:47:20 -0000	3.14
***************
*** 41,51 ****
  Country codes are maintained by the RIPE Network Coordination Centre,
  in coordination with the ISO 3166 Maintenance Agency at DIN Berlin.  The
! authoritative source of counry code mappings is:
  
!     <url:ftp://info.ripe.net/iso3166-countrycodes>
  
  The latest known change to this information was:
  
!     Thu Aug  7 17:59:51 MET DST 1997
  
  This script also knows about non-geographic top-level domains.
--- 41,51 ----
  Country codes are maintained by the RIPE Network Coordination Centre,
  in coordination with the ISO 3166 Maintenance Agency at DIN Berlin.  The
! authoritative source of country code mappings is:
  
!     <url:ftp://ftp.ripe.net/iso3166-countrycodes.txt>
  
  The latest known change to this information was:
  
!     Friday, 5 April 2002, 12.00 CET 2002
  
  This script also knows about non-geographic top-level domains.
***************
*** 89,93 ****
  
  import sys
- import string
  import getopt
  try:
--- 89,92 ----
***************
*** 110,114 ****
  
  def resolve(rawaddr):
!     parts = string.splitfields(rawaddr, '.')
      if not len(parts):
  	# no top level domain found, bounce it to the next step
--- 109,113 ----
  
  def resolve(rawaddr):
!     parts = rawaddr.split('.')
      if not len(parts):
  	# no top level domain found, bounce it to the next step
***************
*** 116,120 ****
      addr = parts[-1]
      if nameorgs.has_key(addr):
!         if string.lower(nameorgs[addr][0]) in 'aeiou':
              ana = 'an'
          else:
--- 115,119 ----
      addr = parts[-1]
      if nameorgs.has_key(addr):
!         if nameorgs[addr][0].lower() in 'aeiou':
              ana = 'an'
          else:
***************
*** 172,176 ****
  	    mo = cre.match(line)
  	    if not mo:
! 		line = string.strip(line)
  		if not line:
  		    continue
--- 171,175 ----
  	    mo = cre.match(line)
  	    if not mo:
! 		line = line.strip()
  		if not line:
  		    continue
***************
*** 182,208 ****
  	    country, code = mo.group(1, 2)
  	    if normalize:
! 		words = string.split(country)
  		for i in range(len(words)):
  		    w = words[i]
  		    # XXX special cases
  		    if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'):
! 			words[i] = string.lower(w)
! 		    elif w == 'THE' and i <> 1:
! 			words[i] = string.lower(w)
  		    elif len(w) > 3 and w[1] == "'":
! 			words[i] = string.upper(w[0:3]) + \
! 				   string.lower(w[3:])
  		    elif w == '(U.S.)':
  			pass
! 		    elif w[0] == '(' and w <> '(local':
! 			words[i] = '(' + string.capitalize(w[1:])
! 		    elif string.find(w, '-'):
! 			words[i] = string.join(
! 			    map(string.capitalize, string.split(w, '-')),
! 			    '-')
  		    else:
! 			words[i] = string.capitalize(w)
! 		code = string.lower(code)
! 		country = string.join(words)
  		print '    "%s": "%s",' % (code, country)
  	    else:
--- 181,204 ----
  	    country, code = mo.group(1, 2)
  	    if normalize:
! 		words = country.split()
  		for i in range(len(words)):
  		    w = words[i]
  		    # XXX special cases
  		    if w in ('AND', 'OF', 'OF)', 'name:', 'METROPOLITAN'):
! 			words[i] = w.lower()
! 		    elif w == 'THE' and i != 1:
! 			words[i] = w.lower()
  		    elif len(w) > 3 and w[1] == "'":
! 			words[i] = w[0:3].upper() + w[3:].lower()
  		    elif w == '(U.S.)':
  			pass
! 		    elif w[0] == '(' and w != '(local':
! 			words[i] = '(' + w[1:].capitalize()
! 		    elif w.find('-') != -1:
! 			words[i] = '-'.join([s.capitalize() for s in w.split('-')])
  		    else:
! 			words[i] = w.capitalize()
! 		code = code.lower()
! 		country = ' '.join(words)
  		print '    "%s": "%s",' % (code, country)
  	    else:
***************
*** 290,294 ****
      # Book' protocols over X.25 to Internet protocols over IP.
      #
!     # See <url:http://www.ripe.net/docs/ripe-159.html#222123>
      "uk": "United Kingdom (common practice)",
      "su": "Soviet Union (still in limited use)",
--- 286,290 ----
      # Book' protocols over X.25 to Internet protocols over IP.
      #
!     # See <url:ftp://ftp.ripe.net/ripe/docs/ripe-159.txt>
      "uk": "United Kingdom (common practice)",
      "su": "Soviet Union (still in limited use)",
***************
*** 351,355 ****
      "cr": "Costa Rica",
      "ci": "Cote D'Ivoire",
!     "hr": "Croatia (local name: Hrvatska)",
      "cu": "Cuba",
      "cy": "Cyprus",
--- 347,351 ----
      "cr": "Costa Rica",
      "ci": "Cote D'Ivoire",
!     "hr": "Croatia",
      "cu": "Cuba",
      "cy": "Cyprus",
***************
*** 372,376 ****
      "fi": "Finland",
      "fr": "France",
-     "fx": "France, metropolitan",
      "gf": "French Guiana",
      "pf": "French Polynesia",
--- 368,371 ----
***************
*** 392,396 ****
      "gy": "Guyana",
      "ht": "Haiti",
!     "hm": "Heard and Mc Donald Islands",
      "va": "Holy See (Vatican City State)",
      "hn": "Honduras",
--- 387,391 ----
      "gy": "Guyana",
      "ht": "Haiti",
!     "hm": "Heard Island and Mcdonald Islands",
      "va": "Holy See (Vatican City State)",
      "hn": "Honduras",
***************
*** 400,404 ****
      "in": "India",
      "id": "Indonesia",
!     "ir": "Iran (Islamic Republic of)",
      "iq": "Iraq",
      "ie": "Ireland",
--- 395,399 ----
      "in": "India",
      "id": "Indonesia",
!     "ir": "Iran, Islamic Republic of",
      "iq": "Iraq",
      "ie": "Ireland",
***************
*** 408,412 ****
      "jp": "Japan",
      "jo": "Jordan",
!     "kz": "Kazakhstan",
      "ke": "Kenya",
      "ki": "Kiribati",
--- 403,407 ----
      "jp": "Japan",
      "jo": "Jordan",
!     "kz": "Kazakstan",
      "ke": "Kenya",
      "ki": "Kiribati",
***************
*** 463,466 ****
--- 458,462 ----
      "pk": "Pakistan",
      "pw": "Palau",
+     "ps": "Palestinian Territory, Occupied",
      "pa": "Panama",
      "pg": "Papua New Guinea",
***************
*** 477,482 ****
--- 473,480 ----
      "ru": "Russian Federation",
      "rw": "Rwanda",
+     "sh": "Saint Helena",
      "kn": "Saint Kitts and Nevis",
      "lc": "Saint Lucia",
+     "pm": "Saint Pierre and Miquelon",
      "vc": "Saint Vincent and the Grenadines",
      "ws": "Samoa",
***************
*** 488,492 ****
      "sl": "Sierra Leone",
      "sg": "Singapore",
!     "sk": "Slovakia (Slovak Republic)",
      "si": "Slovenia",
      "sb": "Solomon Islands",
--- 486,490 ----
      "sl": "Sierra Leone",
      "sg": "Singapore",
!     "sk": "Slovakia",
      "si": "Slovenia",
      "sb": "Solomon Islands",
***************
*** 496,504 ****
      "es": "Spain",
      "lk": "Sri Lanka",
-     "sh": "St. Helena",
-     "pm": "St. Pierre and Miquelon",
      "sd": "Sudan",
      "sr": "Suriname",
!     "sj": "Svalbard and Jan Mayen Islands",
      "sz": "Swaziland",
      "se": "Sweden",
--- 494,500 ----
      "es": "Spain",
      "lk": "Sri Lanka",
      "sd": "Sudan",
      "sr": "Suriname",
!     "sj": "Svalbard and Jan Mayen",
      "sz": "Swaziland",
      "se": "Sweden",
***************
*** 529,535 ****
      "ve": "Venezuela",
      "vn": "Viet Nam",
!     "vg": "Virgin Islands (British)",
!     "vi": "Virgin Islands (U.S.)",
!     "wf": "Wallis and Futuna Islands",
      "eh": "Western Sahara",
      "ye": "Yemen",
--- 525,531 ----
      "ve": "Venezuela",
      "vn": "Viet Nam",
!     "vg": "Virgin Islands, British",
!     "vi": "Virgin Islands, U.s.",
!     "wf": "Wallis and Futuna",
      "eh": "Western Sahara",
      "ye": "Yemen",