PageRenderTime 23ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/django/contrib/localflavor/us/us_states.py

https://code.google.com/p/mango-py/
Python | 326 lines | 316 code | 0 blank | 10 comment | 0 complexity | 980d39ad4a9f712821faa3d05204474c MD5 | raw file
Possible License(s): BSD-3-Clause
  1. """
  2. A mapping of state misspellings/abbreviations to normalized
  3. abbreviations, and alphabetical lists of US states, territories,
  4. military mail regions and non-US states to which the US provides
  5. postal service.
  6. This exists in this standalone file so that it's only imported into memory
  7. when explicitly needed.
  8. """
  9. # The 48 contiguous states, plus the District of Columbia.
  10. CONTIGUOUS_STATES = (
  11. ('AL', 'Alabama'),
  12. ('AZ', 'Arizona'),
  13. ('AR', 'Arkansas'),
  14. ('CA', 'California'),
  15. ('CO', 'Colorado'),
  16. ('CT', 'Connecticut'),
  17. ('DE', 'Delaware'),
  18. ('DC', 'District of Columbia'),
  19. ('FL', 'Florida'),
  20. ('GA', 'Georgia'),
  21. ('ID', 'Idaho'),
  22. ('IL', 'Illinois'),
  23. ('IN', 'Indiana'),
  24. ('IA', 'Iowa'),
  25. ('KS', 'Kansas'),
  26. ('KY', 'Kentucky'),
  27. ('LA', 'Louisiana'),
  28. ('ME', 'Maine'),
  29. ('MD', 'Maryland'),
  30. ('MA', 'Massachusetts'),
  31. ('MI', 'Michigan'),
  32. ('MN', 'Minnesota'),
  33. ('MS', 'Mississippi'),
  34. ('MO', 'Missouri'),
  35. ('MT', 'Montana'),
  36. ('NE', 'Nebraska'),
  37. ('NV', 'Nevada'),
  38. ('NH', 'New Hampshire'),
  39. ('NJ', 'New Jersey'),
  40. ('NM', 'New Mexico'),
  41. ('NY', 'New York'),
  42. ('NC', 'North Carolina'),
  43. ('ND', 'North Dakota'),
  44. ('OH', 'Ohio'),
  45. ('OK', 'Oklahoma'),
  46. ('OR', 'Oregon'),
  47. ('PA', 'Pennsylvania'),
  48. ('RI', 'Rhode Island'),
  49. ('SC', 'South Carolina'),
  50. ('SD', 'South Dakota'),
  51. ('TN', 'Tennessee'),
  52. ('TX', 'Texas'),
  53. ('UT', 'Utah'),
  54. ('VT', 'Vermont'),
  55. ('VA', 'Virginia'),
  56. ('WA', 'Washington'),
  57. ('WV', 'West Virginia'),
  58. ('WI', 'Wisconsin'),
  59. ('WY', 'Wyoming'),
  60. )
  61. # All 50 states, plus the District of Columbia.
  62. US_STATES = (
  63. ('AL', 'Alabama'),
  64. ('AK', 'Alaska'),
  65. ('AZ', 'Arizona'),
  66. ('AR', 'Arkansas'),
  67. ('CA', 'California'),
  68. ('CO', 'Colorado'),
  69. ('CT', 'Connecticut'),
  70. ('DE', 'Delaware'),
  71. ('DC', 'District of Columbia'),
  72. ('FL', 'Florida'),
  73. ('GA', 'Georgia'),
  74. ('HI', 'Hawaii'),
  75. ('ID', 'Idaho'),
  76. ('IL', 'Illinois'),
  77. ('IN', 'Indiana'),
  78. ('IA', 'Iowa'),
  79. ('KS', 'Kansas'),
  80. ('KY', 'Kentucky'),
  81. ('LA', 'Louisiana'),
  82. ('ME', 'Maine'),
  83. ('MD', 'Maryland'),
  84. ('MA', 'Massachusetts'),
  85. ('MI', 'Michigan'),
  86. ('MN', 'Minnesota'),
  87. ('MS', 'Mississippi'),
  88. ('MO', 'Missouri'),
  89. ('MT', 'Montana'),
  90. ('NE', 'Nebraska'),
  91. ('NV', 'Nevada'),
  92. ('NH', 'New Hampshire'),
  93. ('NJ', 'New Jersey'),
  94. ('NM', 'New Mexico'),
  95. ('NY', 'New York'),
  96. ('NC', 'North Carolina'),
  97. ('ND', 'North Dakota'),
  98. ('OH', 'Ohio'),
  99. ('OK', 'Oklahoma'),
  100. ('OR', 'Oregon'),
  101. ('PA', 'Pennsylvania'),
  102. ('RI', 'Rhode Island'),
  103. ('SC', 'South Carolina'),
  104. ('SD', 'South Dakota'),
  105. ('TN', 'Tennessee'),
  106. ('TX', 'Texas'),
  107. ('UT', 'Utah'),
  108. ('VT', 'Vermont'),
  109. ('VA', 'Virginia'),
  110. ('WA', 'Washington'),
  111. ('WV', 'West Virginia'),
  112. ('WI', 'Wisconsin'),
  113. ('WY', 'Wyoming'),
  114. )
  115. # Non-state territories.
  116. US_TERRITORIES = (
  117. ('AS', 'American Samoa'),
  118. ('GU', 'Guam'),
  119. ('MP', 'Northern Mariana Islands'),
  120. ('PR', 'Puerto Rico'),
  121. ('VI', 'Virgin Islands'),
  122. )
  123. # Military postal "states". Note that 'AE' actually encompasses
  124. # Europe, Canada, Africa and the Middle East.
  125. ARMED_FORCES_STATES = (
  126. ('AA', 'Armed Forces Americas'),
  127. ('AE', 'Armed Forces Europe'),
  128. ('AP', 'Armed Forces Pacific'),
  129. )
  130. # Non-US locations serviced by USPS (under Compact of Free
  131. # Association).
  132. COFA_STATES = (
  133. ('FM', 'Federated States of Micronesia'),
  134. ('MH', 'Marshall Islands'),
  135. ('PW', 'Palau'),
  136. )
  137. # Obsolete abbreviations (no longer US territories/USPS service, or
  138. # code changed).
  139. OBSOLETE_STATES = (
  140. ('CM', 'Commonwealth of the Northern Mariana Islands'), # Is now 'MP'
  141. ('CZ', 'Panama Canal Zone'), # Reverted to Panama 1979
  142. ('PI', 'Philippine Islands'), # Philippine independence 1946
  143. ('TT', 'Trust Territory of the Pacific Islands'), # Became the independent COFA states + Northern Mariana Islands 1979-1994
  144. )
  145. # All US states and territories plus DC and military mail.
  146. STATE_CHOICES = tuple(sorted(US_STATES + US_TERRITORIES + ARMED_FORCES_STATES, key=lambda obj: obj[1]))
  147. # All US Postal Service locations.
  148. USPS_CHOICES = tuple(sorted(US_STATES + US_TERRITORIES + ARMED_FORCES_STATES + COFA_STATES, key=lambda obj: obj[1]))
  149. STATES_NORMALIZED = {
  150. 'ak': 'AK',
  151. 'al': 'AL',
  152. 'ala': 'AL',
  153. 'alabama': 'AL',
  154. 'alaska': 'AK',
  155. 'american samao': 'AS',
  156. 'american samoa': 'AS',
  157. 'ar': 'AR',
  158. 'ariz': 'AZ',
  159. 'arizona': 'AZ',
  160. 'ark': 'AR',
  161. 'arkansas': 'AR',
  162. 'as': 'AS',
  163. 'az': 'AZ',
  164. 'ca': 'CA',
  165. 'calf': 'CA',
  166. 'calif': 'CA',
  167. 'california': 'CA',
  168. 'co': 'CO',
  169. 'colo': 'CO',
  170. 'colorado': 'CO',
  171. 'conn': 'CT',
  172. 'connecticut': 'CT',
  173. 'ct': 'CT',
  174. 'dc': 'DC',
  175. 'de': 'DE',
  176. 'del': 'DE',
  177. 'delaware': 'DE',
  178. 'deleware': 'DE',
  179. 'district of columbia': 'DC',
  180. 'fl': 'FL',
  181. 'fla': 'FL',
  182. 'florida': 'FL',
  183. 'ga': 'GA',
  184. 'georgia': 'GA',
  185. 'gu': 'GU',
  186. 'guam': 'GU',
  187. 'hawaii': 'HI',
  188. 'hi': 'HI',
  189. 'ia': 'IA',
  190. 'id': 'ID',
  191. 'idaho': 'ID',
  192. 'il': 'IL',
  193. 'ill': 'IL',
  194. 'illinois': 'IL',
  195. 'in': 'IN',
  196. 'ind': 'IN',
  197. 'indiana': 'IN',
  198. 'iowa': 'IA',
  199. 'kan': 'KS',
  200. 'kans': 'KS',
  201. 'kansas': 'KS',
  202. 'kentucky': 'KY',
  203. 'ks': 'KS',
  204. 'ky': 'KY',
  205. 'la': 'LA',
  206. 'louisiana': 'LA',
  207. 'ma': 'MA',
  208. 'maine': 'ME',
  209. 'marianas islands': 'MP',
  210. 'marianas islands of the pacific': 'MP',
  211. 'marinas islands of the pacific': 'MP',
  212. 'maryland': 'MD',
  213. 'mass': 'MA',
  214. 'massachusetts': 'MA',
  215. 'massachussetts': 'MA',
  216. 'md': 'MD',
  217. 'me': 'ME',
  218. 'mi': 'MI',
  219. 'mich': 'MI',
  220. 'michigan': 'MI',
  221. 'minn': 'MN',
  222. 'minnesota': 'MN',
  223. 'miss': 'MS',
  224. 'mississippi': 'MS',
  225. 'missouri': 'MO',
  226. 'mn': 'MN',
  227. 'mo': 'MO',
  228. 'mont': 'MT',
  229. 'montana': 'MT',
  230. 'mp': 'MP',
  231. 'ms': 'MS',
  232. 'mt': 'MT',
  233. 'n d': 'ND',
  234. 'n dak': 'ND',
  235. 'n h': 'NH',
  236. 'n j': 'NJ',
  237. 'n m': 'NM',
  238. 'n mex': 'NM',
  239. 'nc': 'NC',
  240. 'nd': 'ND',
  241. 'ne': 'NE',
  242. 'neb': 'NE',
  243. 'nebr': 'NE',
  244. 'nebraska': 'NE',
  245. 'nev': 'NV',
  246. 'nevada': 'NV',
  247. 'new hampshire': 'NH',
  248. 'new jersey': 'NJ',
  249. 'new mexico': 'NM',
  250. 'new york': 'NY',
  251. 'nh': 'NH',
  252. 'nj': 'NJ',
  253. 'nm': 'NM',
  254. 'nmex': 'NM',
  255. 'north carolina': 'NC',
  256. 'north dakota': 'ND',
  257. 'northern mariana islands': 'MP',
  258. 'nv': 'NV',
  259. 'ny': 'NY',
  260. 'oh': 'OH',
  261. 'ohio': 'OH',
  262. 'ok': 'OK',
  263. 'okla': 'OK',
  264. 'oklahoma': 'OK',
  265. 'or': 'OR',
  266. 'ore': 'OR',
  267. 'oreg': 'OR',
  268. 'oregon': 'OR',
  269. 'pa': 'PA',
  270. 'penn': 'PA',
  271. 'pennsylvania': 'PA',
  272. 'pr': 'PR',
  273. 'puerto rico': 'PR',
  274. 'rhode island': 'RI',
  275. 'ri': 'RI',
  276. 's dak': 'SD',
  277. 'sc': 'SC',
  278. 'sd': 'SD',
  279. 'sdak': 'SD',
  280. 'south carolina': 'SC',
  281. 'south dakota': 'SD',
  282. 'tenn': 'TN',
  283. 'tennessee': 'TN',
  284. 'territory of hawaii': 'HI',
  285. 'tex': 'TX',
  286. 'texas': 'TX',
  287. 'tn': 'TN',
  288. 'tx': 'TX',
  289. 'us virgin islands': 'VI',
  290. 'usvi': 'VI',
  291. 'ut': 'UT',
  292. 'utah': 'UT',
  293. 'va': 'VA',
  294. 'vermont': 'VT',
  295. 'vi': 'VI',
  296. 'viginia': 'VA',
  297. 'virgin islands': 'VI',
  298. 'virgina': 'VA',
  299. 'virginia': 'VA',
  300. 'vt': 'VT',
  301. 'w va': 'WV',
  302. 'wa': 'WA',
  303. 'wash': 'WA',
  304. 'washington': 'WA',
  305. 'west virginia': 'WV',
  306. 'wi': 'WI',
  307. 'wis': 'WI',
  308. 'wisc': 'WI',
  309. 'wisconsin': 'WI',
  310. 'wv': 'WV',
  311. 'wva': 'WV',
  312. 'wy': 'WY',
  313. 'wyo': 'WY',
  314. 'wyoming': 'WY',
  315. }