Mercurial > hg > TextShaper
comparison textshaper/indent.py @ 34:88a69d587326
round1 of commands
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Sun, 02 Mar 2014 15:33:07 -0800 |
| parents | 23616399f36c |
| children |
comparison
equal
deleted
inserted
replaced
| 33:de3148412191 | 34:88a69d587326 |
|---|---|
| 41 index = indentation | 41 index = indentation |
| 42 retval.append(line[index:]) | 42 retval.append(line[index:]) |
| 43 | 43 |
| 44 return retval | 44 return retval |
| 45 | 45 |
| 46 @lines | |
| 47 def deindent(text): | |
| 48 """strip lines""" | |
| 49 return [line.strip() for line in text] | |
| 50 | |
| 51 ### CLI | |
| 46 | 52 |
| 47 def add_arguments(parser): | 53 def add_arguments(parser): |
| 48 parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), | 54 parser.add_argument('infile', nargs='?', type=argparse.FileType('r'), |
| 49 default=sys.stdin) | 55 default=sys.stdin) |
| 50 parser.add_argument('-o', '--output', dest='output', | 56 parser.add_argument('-o', '--output', dest='output', |
| 51 help="output file or stdout if not given") | 57 help="output file or stdout if not given") |
| 52 | 58 |
| 53 | 59 |
| 54 def main(args=sys.argv[1:]): | 60 def main(args=sys.argv[1:]): |
| 61 """CLI""" | |
| 55 | 62 |
| 56 # parse command line | 63 # parse command line |
| 57 description = """indent files or stdin if no files given""" | 64 description = """indent files or stdin if no files given""" |
| 58 parser = argparse.Argument(description=__doc__) | 65 parser = argparse.Argument(description=__doc__) |
| 59 add_arguments(parser) | 66 add_arguments(parser) |
