Mercurial > hg > config
diff python/str2lnk.py @ 0:f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
author | k0s <k0scist@gmail.com> |
---|---|
date | Thu, 15 Oct 2009 11:41:26 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/str2lnk.py Thu Oct 15 11:41:26 2009 -0400 @@ -0,0 +1,24 @@ +#!/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)