Mercurial > hg > config
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f3ab51c79813 |
---|---|
1 #!/usr/bin/python | |
2 | |
3 def str2lnk(string): | |
4 """transform a string to a legitimate link name for html""" | |
5 illegal_characters=' @,?/\\#' | |
6 for i in illegal_characters: | |
7 string = string.replace(i, '_') | |
8 newstring = '' | |
9 for i in string.split('_'): | |
10 if i: | |
11 newstring += i + '_' | |
12 return newstring[:-1] | |
13 | |
14 if __name__ == '__main__': | |
15 import sys | |
16 try: | |
17 newstring=sys.argv[1] | |
18 except IndexError: | |
19 print '%s' % str2lnk.__doc__ | |
20 print 'Usage: %s <string to be made a link>' % sys.argv[0] | |
21 sys.exit(0) | |
22 | |
23 newstring = ' '.join(sys.argv) | |
24 print str2lnk(newstring) |