Anonymous avatar Anonymous committed dc0dc96

uk_countries() returns tuples, and docstring cleanup.

Comments (0)

Files changed (2)

 WebHelpers ChangeLog
 
 1.0b1 (tip)
+* webhelpers.constants:
+  - ``uk_counties`` returns tuples rather than lists.
 * webhelpers.feedgenerator:
   - ``rfc3339_date`` now accepts date objects without crashing.
 * webhelpers.html.converters:

webhelpers/constants.py

 # -*- encoding: latin-1 -*-
 # Latin-1 encoding needed for countries list.
 """Geographical and other constants often used in web forms.
-
-The timezone functions have been removed.  Install the PyTZ package if you
-need them.
 """
 
 def uk_counties():
     """\
-    Returns a list of UK county names based on data from http://www.gbet.com/AtoZ_counties/
-    Last updated on 2007-10-24.
+    Return a list of UK county names.
     """
+    # Based on http://www.gbet.com/AtoZ_counties/
+    # Updated 2007-10-24
     return [x.strip()[2:] for x in """\
     * Avon
     * Bedfordshire
 _country_codes = None
 def country_codes():
     """\
-    Return a list of all country names and their respective codes specified by the ISO in the format::
+    Return a list of all country names and their respective codes specified by
+    the ISO in the format ``("GB", "United Kingdom")``
     
-        [
-            ...
-            ['GB', 'United Kingodom],
-            ...
-        ]
-
-    See here for more information:
-    http://www.iso.org/iso/english_country_names_and_code_elements
-
     Can be used like this::
 
         h.select(
             ),
         )
 
-    Last updated on 2007-10-24.
+    See here for more information:
+    http://www.iso.org/iso/english_country_names_and_code_elements
     """
+    # Updated on 2007-10-24.
+    #
     # This might seem a funny implementation but it makes it easier to updated next
     # time there is a change
 
                 if part.strip():
                     p.append(part.strip())
             if len(p)>2:
-                raise Exception("Invalid entry %s"%p)
+                raise Exception("Invalid entry %s" % p)
 
             p.reverse()
             if len(p) == 1:
                 else:
                     # We just want to ignore it
                     continue
+            p = tuple(p)
             e.append(p)
     _country_codes = e
     return _country_codes
 
     Return a list of (abbreviation, name) for all US states, sorted by name.
     Includes the District of Columbia.
-
-    From http://www.usps.com/ncsc/lookups/abbreviations.html
-    Updated 2008-05-01
     """
+    # From http://www.usps.com/ncsc/lookups/abbreviations.html
+    #Updated 2008-05-01
     return [
         ("AL", "Alabama"),
         ("AK", "Alaska"),
 
 def us_territories():
     """USA postal abbreviations for territories, protectorates, and military.
-
-    From http://www.usps.com/ncsc/lookups/abbreviations.html
-    Updated 2008-05-01
     """
+    # From http://www.usps.com/ncsc/lookups/abbreviations.html
+    # Updated 2008-05-01
     return [
         ("AS", "American Samoa"),
         ("AA", "Armed Forces Americas"),
 
     Return a list of (abbreviation, name) for all Canadian
     provinces and territories, sorted by name.
-
-    Transcribed from Wikipedia on 2008-05-01.
-    http://en.wikipedia.org/wiki/Canadian_subnational_postal_abbreviations
-
-    See also
-    http://en.wikipedia.org/wiki/Provinces_and_territories_of_Canada
     """
+    # Based on:
+    # http://en.wikipedia.org/wiki/Canadian_subnational_postal_abbreviations
+    # See also: 
+    # http://en.wikipedia.org/wiki/Provinces_and_territories_of_Canada
+    # Updated 2008-05-01
     provinces = [
         ("Alberta", "AB"),
         ("British Columbia", "BC"),
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.