Mercurial > hg > svgsitemap
comparison svgsitemap/url.py @ 14:2916206a6807
add a stub for URL shortening
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Sun, 02 Jan 2011 11:57:04 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
13:6cf3539cfa9c | 14:2916206a6807 |
---|---|
1 """ | |
2 utilities for URLs | |
3 """ | |
4 | |
5 import urlparse | |
6 | |
7 def shorten(url, length): | |
8 """shorten a URL preserving readability""" | |
9 | |
10 if len(url) < length: | |
11 # don't need to do anything | |
12 return url | |
13 | |
14 parsed = urlparse.urlsplit(url) | |
15 import pdb; pdb.set_trace() | |
16 | |
17 if __name__ == '__main__': | |
18 from optparse import OptionParser | |
19 parser = OptionParser() | |
20 parser.add_option('-l', '--length', dest='length', | |
21 default=20, type='int', | |
22 help='maximum URL length') | |
23 options, args = parser.parse_args() | |
24 for arg in args: | |
25 print shorten(arg, options.length) |