<commit_before>"""Main method"""
import argparse
import sys

from botbot import __version__
from . import checks, schecks, checker, sqlcache
from . import ignore as ig
from . import daemon

def main():
    parser = argparse.ArgumentParser(description="Manage lab computational resources.")

    # Verbosity and output options
    verbosity = parser.add_mutually_exclusive_group()
    verbosity.add_argument('-v', '--verbose',
                           help='Print issues and fixes for all files',
                           action='store_true')
    parser.add_argument('-o', '--out',
                        help='Print the report to a file',
                        action='store')
    parser.add_argument('-f', '--format',
                        help='Specify the output format',
                        action='store',
                        default='generic')
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s {}'.format(__version__))

    # Recheck options
    recheck = parser.add_mutually_exclusive_group()
    recheck.add_argument('-c', '--cached',
                        action='store_true',
                        help='Only return cached issues (no recheck)')
    recheck.add_argument('-k', '--force-recheck',
                        action='store_true',
                        help='Force a recheck of the tree')

    # Directory options
    parser.add_argument('path',
                        help='Path to check')
    parser.add_argument('-s', '--shared',
                        help='Use the shared folder ruleset',
                        action='store_true')

    parser.add_argument('-l', '--follow-symlinks',
                        help='Follow symlinks',
                        action='store_true')

    # Daemon options
    parser.add_argument('-d', '--daemon',
                        help='Run as a daemon',
                        action='store_true')

    # Initialize the checker
    args = parser.parse_args()

    # Determine if we should write to a file or to stdout. If a file
    # argument isn't given, default to stdout.
    out = None
    if args.out is not None:
        out = args.out
    else:
        out = sys.stdout

    # Give a list of checking functions to the Checker object so we
    # can go hog-wild with checks.
    clist = (checks.is_fastq,
             checks.sam_should_compress,
             checks.is_large_plaintext,
             schecks.file_groupreadable,
             schecks.file_group_executable,
             schecks.dir_group_readable)

    if args.daemon:
        c = daemon.DaemonizedChecker(args.path)
        c.register(*clist)
        c.init((c.check_file, daemon._EVENT_MASK))
        c.run()
    else:
        c = checker.OneshotChecker(out, sqlcache.get_dbpath())
        c.register(*clist)

    # Get ignore rules from ~/.botbotignore
    ignore = ig.parse_ignore_rules(ig.find_ignore_file())

    # Check the given directory
    c.check_all(args.path,
                cached=args.cached,
                force=args.force_recheck,
                shared=args.shared,
                link=args.follow_symlinks,
                verbose=args.verbose,
                fmt=args.format,
                ignore=ignore)<commit_msg>Fix error with rechecking deleted files<commit_after>"""Main method"""
import argparse
import sys

from botbot import __version__
from . import checks, schecks, checker, sqlcache
from . import ignore as ig
from . import daemon

def main():
    parser = argparse.ArgumentParser(description="Manage lab computational resources.")

    # Verbosity and output options
    verbosity = parser.add_mutually_exclusive_group()
    verbosity.add_argument('-v', '--verbose',
                           help='Print issues and fixes for all files',
                           action='store_true')
    parser.add_argument('-o', '--out',
                        help='Print the report to a file',
                        action='store')
    parser.add_argument('-f', '--format',
                        help='Specify the output format',
                        action='store',
                        default='generic')
    parser.add_argument('--version',
                        action='version',
                        version='%(prog)s {}'.format(__version__))

    # Recheck options
    recheck = parser.add_mutually_exclusive_group()
    recheck.add_argument('-c', '--cached',
                        action='store_true',
                        help='Only return cached issues (no recheck)')
    recheck.add_argument('-k', '--force-recheck',
                        action='store_true',
                        help='Force a recheck of the tree')

    # Directory options
    parser.add_argument('path',
                        help='Path to check')
    parser.add_argument('-s', '--shared',
                        help='Use the shared folder ruleset',
                        action='store_true')

    parser.add_argument('-l', '--follow-symlinks',
                        help='Follow symlinks',
                        action='store_true')

    # Daemon options
    parser.add_argument('-d', '--daemon',
                        help='Run as a daemon',
                        action='store_true')

    # Initialize the checker
    args = parser.parse_args()

    # Determine if we should write to a file or to stdout. If a file
    # argument isn't given, default to stdout.
    out = None
    if args.out is not None:
        out = args.out
    else:
        out = sys.stdout

    # Give a list of checking functions to the Checker object so we
    # can go hog-wild with checks.
    clist = (checks.is_fastq,
             checks.sam_should_compress,
             checks.is_large_plaintext,
             schecks.file_groupreadable,
             schecks.file_group_executable,
             schecks.dir_group_readable)

    if args.daemon:
        c = daemon.DaemonizedChecker(args.path)
        c.register(*clist)
        c.init((c.check_file, daemon._RECHECK_MASK))
        c.run()
    else:
        c = checker.OneshotChecker(out, sqlcache.get_dbpath())
        c.register(*clist)

    # Get ignore rules from ~/.botbotignore
    ignore = ig.parse_ignore_rules(ig.find_ignore_file())

    # Check the given directory
    c.check_all(args.path,
                cached=args.cached,
                force=args.force_recheck,
                shared=args.shared,
                link=args.follow_symlinks,
                verbose=args.verbose,
                fmt=args.format,
                ignore=ignore)
{'fraction_non_alphanumeric': 0.1028293276543961, 'fraction_numerical': 0.0, 'mean_word_length': 1.7556580050293378, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '757048', 'n_tokens_mistral': 1823, 'n_tokens_neox': 1728, 'n_words': 426}