view python/url2txt.py @ 599:782dc37492c4

STUB: python/multiproc.py
author Jeff Hammel <k0scist@gmail.com>
date Thu, 30 Jan 2014 12:45:45 -0800
parents 38dd72d72086
children
line wrap: on
line source

#!/usr/bin/env python

# TODO: add url2txt as pluggable thingy for smartopen

# 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:]))