comparison python/url2txt.py @ 361:5e0b4ec36013

add another textshaper thingy
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 04 Jul 2013 16:01:38 -0700
parents
children 38dd72d72086
comparison
equal deleted inserted replaced
360:d0da972238d0 361:5e0b4ec36013
1 #!/usr/bin/env python
2
3 # xclip -o | sed 's/_//' | sed 's/.html//'
4
5 def url2txt(url):
6 """gets the text equivalent of a URL"""
7 url = url.rstrip('/')
8 if '/' in url:
9 url = url.rsplit('/')[-1]
10 if '.' in url:
11 url = url.split('.', 1)[0]
12 url = url.replace('_', ' ')
13 return url
14
15 if __name__ == '__main__':
16 import sys
17 print url2txt(' '.join(sys.argv[1:]))