def runner(Options, buffering=True):
    """
    Return a standard "run" function that wraps an Options class

    If buffering=False, turn off stdout/stderr buffering for this process
    """
    def run(argv=None):
        if not buffering:
            sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 0)
            sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 0)

        if argv is None:
            argv = sys.argv
        o = Options()
        try:
            o.parseOptions(argv[1:])
        except usage.UsageError, e:
            if hasattr(o, 'subOptions'):
                print str(o.subOptions)
            else:
                print str(o)
            print str(e)
            return 1

        return 0

    return run
def runner ( Options , buffering = True ) : def run ( argv = None ) : if not buffering : sys . stdout = os . fdopen ( sys . stdout . fileno ( ) , 'w' , 0 ) sys . stderr = os . fdopen ( sys . stderr . fileno ( ) , 'w' , 0 ) if argv is None : argv = sys . argv o = Options ( ) try : o . parseOptions ( argv [ 1 : ] ) except usage . UsageError , e : if hasattr ( o , 'subOptions' ) : print str ( o . subOptions ) else : print str ( o ) print str ( e ) return 1 return 0 return run
Return a standard "run" function that wraps an Options class

    If buffering=False, turn off stdout/stderr buffering for this process