Customizable Lazy Exploit Pattern Utility.

def main(argument, sets, big_endian, optimal, output, clipboard,
         quiet, verbose):
    """Customizable Lazy Exploit Pattern Utility."""
    logger = logging.getLogger()
    handler = logging.StreamHandler(sys.stderr)
    handler.setFormatter(LevelFormatter())
    logger.addHandler(handler)
    logger.setLevel(logging.WARNING + (quiet-verbose)*10)

    if sets and optimal:
        pat = Pat.from_chars(''.join(sets), optimal)
    elif optimal:
        pat = Pat.from_chars(optimal=optimal)
    elif sets:
        pat = Pat(sets)
    else:
        pat = Pat()

    if argument.isdigit():
        count = int(argument)
        try:
            pattern = pat.create(count)
        except IndexError:
            logging.exception(_('Failed to create the pattern.'))
            sys.exit(1)
        else:
            if output:
                output.write(pattern)
            elif clipboard:
                copy(pattern)
            else:
                print(pattern)
    else:
        target = argument
        try:
            index = pat.locate(target, big_endian)
        except KeyError:
            logging.exception(_('Failed to locate the pattern.'))
            sys.exit(1)
        else:
            print(index)

    sys.exit(0)