0
|
1 #!/usr/bin/env python
|
|
2 # -*- coding: utf-8 -*-
|
|
3
|
|
4 """
|
4
|
5 package to shape text blocks
|
0
|
6 """
|
|
7
|
|
8 import optparse
|
|
9 import os
|
|
10 import subprocess
|
|
11 import sys
|
3
|
12 import time
|
0
|
13
|
5
|
14 def display(content):
|
4
|
15 print content
|
|
16 print '--'
|
|
17 nlines = len(content.splitlines())
|
|
18 print '%d lines' % nlines
|
|
19
|
0
|
20 def add_options(parser):
|
|
21 """add options to the OptionParser instance"""
|
|
22
|
|
23 def main(args=sys.argv[1:]):
|
|
24
|
|
25 # parse command line options
|
|
26 usage = '%prog [options] ...'
|
|
27 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
|
|
28 """description formatter for console script entry point"""
|
|
29 def format_description(self, description):
|
|
30 if description:
|
|
31 return description.strip() + '\n'
|
|
32 else:
|
|
33 return ''
|
|
34 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
|
|
35 options, args = parser.parse_args(args)
|
|
36
|
3
|
37 # read from stdin
|
|
38 content = sys.stdin.read()
|
|
39
|
|
40 # print formatted content
|
4
|
41 display(content)
|
3
|
42
|
|
43 while True:
|
|
44 time.sleep(1) # XXX
|
|
45
|
0
|
46 if __name__ == '__main__':
|
|
47 main()
|
|
48
|