81
|
1 #!/usr/bin/env python
|
|
2
|
|
3 import sys
|
|
4 import urllib2
|
|
5
|
|
6 def a8e(text):
|
|
7 text = text.split()
|
|
8 retval = []
|
|
9 for word in text:
|
|
10 if len(word) < 4:
|
|
11 retval.append(word)
|
|
12 else:
|
82
|
13 retval.append(word[0] + '%d' % (len(word) - 2) + word[-1])
|
81
|
14 return ' '.join(retval)
|
|
15
|
|
16 def main(args=sys.argv[1:]):
|
|
17 if len(args) == 1 and (args[0].startswith('http://')
|
|
18 or args[0].startswith('https://')):
|
|
19 text = urllib2.urlopen(args[0]).read()
|
|
20 else:
|
|
21 text = ' '.join(args)
|
|
22 # TODO: read from stdin if no args
|
|
23 print a8e(text)
|
|
24
|
|
25 if __name__ == '__main__':
|
|
26 main()
|
|
27
|