changeset 14:2916206a6807

add a stub for URL shortening
author Jeff Hammel <jhammel@mozilla.com>
date Sun, 02 Jan 2011 11:57:04 -0800
parents 6cf3539cfa9c
children 61038b4e7425
files svgsitemap/url.py
diffstat 1 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /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)