Mercurial > hg > config
comparison python/tippytodos.py @ 618:5ab1df94cc8d
read TODOs from directory tree (unfinished)
| author | Jeff Hammel <k0scist@gmail.com> |
|---|---|
| date | Mon, 03 Feb 2014 13:29:12 -0800 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 617:3da0a7caf07e | 618:5ab1df94cc8d |
|---|---|
| 1 #!/usr/bin/env python | |
| 2 # -*- coding: utf-8 -*- | |
| 3 | |
| 4 import argparse | |
| 5 import os | |
| 6 import sys | |
| 7 from subprocess import check_output | |
| 8 | |
| 9 def call(command, **kwargs): | |
| 10 kwargs.setdefault('shell', True) | |
| 11 print (command) | |
| 12 return check_output(command, **kwargs) | |
| 13 | |
| 14 def main(args=sys.argv[1:]): | |
| 15 | |
| 16 usage = '%prog [options]' | |
| 17 parser = argparse.ArgumentParser(usage=usage, description=__doc__) | |
| 18 parser.add_argument('--mark', dest='mark', default='#') | |
| 19 parser.add_argument('-d', '--directory', dest='directory', default='.') | |
| 20 parser.add_argument('-p', '--pattern', dest='pattern', default='*.py') | |
| 21 options = parser.parse_args(args) | |
| 22 | |
| 23 command = ['find', options.directory, '-iname', options.pattern, | |
| 24 '|', | |
| 25 'grep', '' ... ] # to finish | |
| 26 | |
| 27 output = check_output(subprocess.list2cmdline(command)) | |
| 28 | |
| 29 if __name__ == '__main__': | |
| 30 main() |
