Permalink
Browse files

Merge pull request #7 from linsomniac/master

Adding an "areacode" command to look up US areacodes in wikipedia.
  • Loading branch information...
2 parents b67aa1e + 15db833 commit a4754dd910e87f7369fb5822313c2ea7e14ca7d5 @svetlyak40wt committed Oct 2, 2011
Showing with 32 additions and 0 deletions.
  1. +32 −0 examples/wikiareacode.py
View
@@ -0,0 +1,32 @@
+#!/usr/bin/env python
+
+from bottle import redirect
+from cony import rich_help
+import urllib2
+
+
+@rich_help('--help')
+def cmd_areacode(term):
+ '''Look up an areacode in Wikipedia.'''
+
+ template = """
+ <p />Look up an areacode in Wikipedia.
+ If the term is:
+
+ <ul>
+ <li /><b>No arguments</b> -- Take you to a page on Wikipedia
+ listing US areacodes.
+ <li /><b>Areacode</b> -- Go directly to that
+ areacode's page on Wikipedia.
+ </ul>
+
+ %rebase layout title = 'Areacode Help'
+ """
+
+ if term == '--help' or term == '?' or term == '-?':
+ return dict(template = template)
+ elif not term:
+ redirect('http://en.wikipedia.org/wiki/List_of_NANP_area_codes')
+ else:
+ url = 'http://en.wikipedia.org/wiki/Area_code_%s' % term
+ redirect(url)

0 comments on commit a4754dd

Please sign in to comment.