annotate python/tippytodos.py @ 710:7f910ce4da04

STUB: python/dlna.py
author Jeff Hammel <k0scist@gmail.com>
date Sat, 06 Sep 2014 07:59:16 -0700
parents 5ab1df94cc8d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
618
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
1 #!/usr/bin/env python
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
3
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
4 import argparse
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
5 import os
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
6 import sys
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
7 from subprocess import check_output
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
8
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
9 def call(command, **kwargs):
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
10 kwargs.setdefault('shell', True)
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
11 print (command)
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
12 return check_output(command, **kwargs)
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
13
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
14 def main(args=sys.argv[1:]):
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
15
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
16 usage = '%prog [options]'
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
17 parser = argparse.ArgumentParser(usage=usage, description=__doc__)
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
18 parser.add_argument('--mark', dest='mark', default='#')
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
19 parser.add_argument('-d', '--directory', dest='directory', default='.')
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
20 parser.add_argument('-p', '--pattern', dest='pattern', default='*.py')
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
21 options = parser.parse_args(args)
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
22
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
23 command = ['find', options.directory, '-iname', options.pattern,
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
24 '|',
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
25 'grep', '' ... ] # to finish
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
26
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
27 output = check_output(subprocess.list2cmdline(command))
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
28
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
29 if __name__ == '__main__':
5ab1df94cc8d read TODOs from directory tree (unfinished)
Jeff Hammel <k0scist@gmail.com>
parents:
diff changeset
30 main()