view python/str2lnk.py @ 275:7ffc6b1821f8

http://stackoverflow.com/questions/6397323/how-to-avoid-the-message-of-server-start-while-opening-another-emacs-session sadly doesnt help
author Jeff Hammel <jhammel@mozilla.com>
date Wed, 10 Apr 2013 15:17:19 -0700
parents f3ab51c79813
children
line wrap: on
line source

#!/usr/bin/python

def str2lnk(string):
    """transform a string to a legitimate link name for html"""
    illegal_characters=' @,?/\\#'
    for i in illegal_characters:
        string = string.replace(i, '_')
    newstring = ''
    for i in string.split('_'):
        if i:
            newstring += i + '_'
    return newstring[:-1]
    
if __name__ == '__main__':
    import sys
    try:
        newstring=sys.argv[1]
    except IndexError:
        print '%s' % str2lnk.__doc__
        print 'Usage: %s <string to be made a link>' % sys.argv[0]
        sys.exit(0)

    newstring = ' '.join(sys.argv)
    print str2lnk(newstring)