def main(argv=None):
    """script main.

    parses command line options in sys.argv, unless *argv* is given.
    """

    if argv is None:
        argv = sys.argv

    parser = E.OptionParser(version="%prog version: $Id: clean.py 2782 2009-09-10 11:40:29Z andreas $",
                            usage=globals()["__doc__"])

    parser.add_option("-g", "--glob", dest="glob_pattern", type="string",
                      help="glob pattern to use for collecting files [%default].")

    parser.add_option("-n", "--dry-run", dest="dry_run", action="store_true",
                      help="only print out actions, do not execute them [%default].")

    parser.add_option("-f", "--file-pattern", dest="file_pattern", type="string",
                      help="only check files matching this pattern [%default].")

    parser.set_defaults(glob_pattern="data.dir",
                        file_pattern=".out",
                        check_completeness="python",
                        skip_dirs=[],
                        dry_run=False,
                        )

    (options, args) = E.Start(parser,
                              add_pipe_options=True)

    if args:
        starts = args
    elif options.glob_pattern:
        starts = glob.glob(options.glob_pattern)
    else:
        starts = "."

    ndirs, nfiles, ndeleted = 0, 0, 0

    if options.check_completeness == "python":
        isComplete = checkPythonRuns

    rx = re.compile(options.file_pattern)

    for start in starts:
        for root, dirs, files in os.walk(start):

            ndirs += 1
            # exclude directories
            for dir in options.skip_dirs:
                if dir in dirs:
                    dirs.remove(dir)

            for filename in files:
                p = os.path.join(root, filename)
                if rx.search(filename) and not isComplete(p):
                    if options.dry_run:
                        options.stdlog.write("# removing file %s\n" % p)
                    else:
                        os.remove(p)
                    ndeleted += 1

    if 1 >= options.loglevel:
        options.stdlog.write("# ndirs=%i, nfiles=%i, ndeleted=%i\n" %
                             (ndirs, nfiles, ndeleted))

    E.Stop()
dataset/ETHPy150Open CGATOxford/cgat/scripts/clean.py/main/swapped operands of `>=`