# HG changeset patch # User Jeff Hammel # Date 1293998224 28800 # Node ID 2916206a68072b1eff50957139b4317b9907a859 # Parent 6cf3539cfa9cb586cde6e010f63e401e3bbb96f4 add a stub for URL shortening diff -r 6cf3539cfa9c -r 2916206a6807 svgsitemap/url.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/svgsitemap/url.py Sun Jan 02 11:57:04 2011 -0800 @@ -0,0 +1,25 @@ +""" +utilities for URLs +""" + +import urlparse + +def shorten(url, length): + """shorten a URL preserving readability""" + + if len(url) < length: + # don't need to do anything + return url + + parsed = urlparse.urlsplit(url) + import pdb; pdb.set_trace() + +if __name__ == '__main__': + from optparse import OptionParser + parser = OptionParser() + parser.add_option('-l', '--length', dest='length', + default=20, type='int', + help='maximum URL length') + options, args = parser.parse_args() + for arg in args: + print shorten(arg, options.length)