view python/randomize.py @ 116:2a83052a7a50

add hg defaults from http://blog.bonardo.net/2010/06/22/so-youre-about-to-use-checkin-needed
author Jeff Hammel <jhammel@mozilla.com>
date Thu, 09 Dec 2010 14:49:14 -0800
parents f3ab51c79813
children 12299cbc45ee
line wrap: on
line source

#!/usr/bin/env python

import os
import random
import subprocess
import sys

from optparse import OptionParser

if __name__ == '__main__':
    parser = OptionParser()
    parser.add_option("-e", "--exec", dest="callable",
                      help="program to execute")
    (options, argv) = parser.parse_args()
    args = []
    for i in argv:
        if os.path.isdir(i):
            for root, dirs, files in os.walk(i):
                args.extend([os.path.join(root, f) for f in files])
        else:
            args.append(i)
    random.shuffle(args)
    if options.callable:
        for i in args:
            subprocess.call([options.callable, i])
    else:
        print '\n'.join(args)