Mercurial > hg > config
annotate python/a8e.py @ 694:ebca6d85213a
File "/usr/lib/python3/dist-packages/IPython/config/__init__.py", line 16, in <module>
from .application import *
File "/usr/lib/python3/dist-packages/IPython/config/application.py", line 31, in <module>
from IPython.config.configurable import SingletonConfigurable
File "/usr/lib/python3/dist-packages/IPython/config/configurable.py", line 33, in <module>
from IPython.utils.text import indent, wrap_paragraphs
File "/usr/lib/python3/dist-packages/IPython/utils/text.py", line 28, in <module>
from IPython.external.path import path
File "/usr/lib/python3/dist-packages/IPython/external/path/__init__.py", line 2, in <module>
from path import *
File "/home/jhammel/python/path.py", line 25
print root(path)
^
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Wed, 09 Jul 2014 16:26:49 -0700 |
parents | a7857000e206 |
children |
rev | line source |
---|---|
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 |