Mercurial > hg > config
view python/url2txt.py @ 375:9314c1008189
aslightly better; still trouble at da end
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 24 Jul 2013 03:10:27 -0700 |
parents | 5e0b4ec36013 |
children | 38dd72d72086 |
line wrap: on
line source
#!/usr/bin/env python # xclip -o | sed 's/_//' | sed 's/.html//' def url2txt(url): """gets the text equivalent of a URL""" url = url.rstrip('/') if '/' in url: url = url.rsplit('/')[-1] if '.' in url: url = url.split('.', 1)[0] url = url.replace('_', ' ') return url if __name__ == '__main__': import sys print url2txt(' '.join(sys.argv[1:]))