# HG changeset patch # User Jeff Hammel # Date 1393145106 28800 # Node ID e6f680d25d63004ea7b415d6893688c55e9d1aa7 # Parent 09f4c09d96170fb2eac0d0bfd2a26c749d8add74 migrate url2txt diff -r 09f4c09d9617 -r e6f680d25d63 README.txt --- a/README.txt Sun Feb 23 00:31:09 2014 -0800 +++ b/README.txt Sun Feb 23 00:45:06 2014 -0800 @@ -33,30 +33,12 @@ == Reference == -Previous k0s.ware (big and small): -- http://k0s.org/hg/config/rev/5e0b4ec36013 - Highly related (~> identity): http://k0s.org/portfolio/ideas/cleanuptext.py Ubuntu packages: - par (paragraph reformatter) - - - - - - - - - - - - - - - ---- Jeff Hammel diff -r 09f4c09d9617 -r e6f680d25d63 setup.py --- a/setup.py Sun Feb 23 00:31:09 2014 -0800 +++ b/setup.py Sun Feb 23 00:45:06 2014 -0800 @@ -14,6 +14,7 @@ kw['entry_points'] = """ [console_scripts] textshaper = textshaper.main:main + url2txt = textshaper.url2txt:main """ kw['install_requires'] = dependencies except ImportError: @@ -33,7 +34,7 @@ long_description=description, classifiers=[], # Get strings from http://www.python.org/pypi?%3Aaction=list_classifiers author='Jeff Hammel', - author_email='jhammel@mozilla.com', + author_email='k0scist@gmail.com', url='http://k0s.org/hg/TextShaper', license='MPL2', packages=['textshaper'], diff -r 09f4c09d9617 -r e6f680d25d63 textshaper/url2txt.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/textshaper/url2txt.py Sun Feb 23 00:45:06 2014 -0800 @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +""" +get the human-form of the name of the final path segment in a url: + +xclip -o | sed 's/_//' | sed 's/.html//' +""" + +import sys + +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 + + +def main(args=sys.argv[1:]): + """CLI""" + for arg in args: + print url2txt(arg) + + +if __name__ == '__main__': + main()