Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'master' of github.com:svetlyak40wt/cony

  • Loading branch information...
commit ae81907f50df2a229c453ce8132cc25795555ec3 2 parents fdd87d5 + a4754dd
@svetlyak40wt authored
Showing with 32 additions and 0 deletions.
  1. +32 −0 examples/wikiareacode.py
View
32 examples/wikiareacode.py
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.