<commit_before>#!/usr/bin/env python3

import os
import ocrCore
import time

__author__ = '<NAME>'
__version__ = '0.1.0'  # First separate CLI

DEBUGMODE = False

helpText = \
"""
NAME
    PDFImagesOCR - OCRs PDFs to text

SYNOPSIS
    PDFImagesOCR inFile outType

DESCRIPTION
    A utility that uses OCR to convert a PDF file to a text file or a searchable PDF

OPTIONS
    inFile
        The path to the 'input' file to process.

    outType
        The type of output to produce.
        'pdf' for a searchable PDF
        'txt' for a text file

"""

helpArgs = ['help', 'HELP', '-h', '/h', '-?', '/?', '--help']


class Cli:
    def __init__(self, args):
        if DEBUGMODE:
            print(args)
        printHelpTextAndExitIfNeeded(args)
        inFile = os.path.normpath(args[1])
        outType = args[2]
        core = ocrCore.Ocr(inFile, outType)
        while core.isRunning():
            time.sleep(5)
            print(core.currentTask + ': ' + core.fileName)
            core.updateTick()


def printHelpTextAndExitIfNeeded(args):
    # If the wrong number of args are given, show help and exit
    argCount = len(args)
    if argCount != 3:  # The program, the input file, and the output type
        print("Invalid number of arguments")
        print(helpText)
        exit()

    # If a help argument is given, show help and exit
    for arg in args:
        if arg in helpArgs:
            print(helpText)
            exit()

    if args[2] != 'pdf' and args[2] != 'txt':
        print("Invalid output type: ", args[2])
        print(helpText)<commit_msg>More codeship debugging<commit_after>#!/usr/bin/env python3

import os
import ocrCore
import time

__author__ = '<NAME>'
__version__ = '0.1.0'  # First separate CLI

DEBUGMODE = False

helpText = \
"""
NAME
    PDFImagesOCR - OCRs PDFs to text

SYNOPSIS
    PDFImagesOCR inFile outType

DESCRIPTION
    A utility that uses OCR to convert a PDF file to a text file or a searchable PDF

OPTIONS
    inFile
        The path to the 'input' file to process.

    outType
        The type of output to produce.
        'pdf' for a searchable PDF
        'txt' for a text file

"""

helpArgs = ['help', 'HELP', '-h', '/h', '-?', '/?', '--help']


class Cli:
    def __init__(self, args):
        if DEBUGMODE:
            print(args)
        printHelpTextAndExitIfNeeded(args)
        inFile = os.path.normpath(args[1])
        outType = args[2]
        core = ocrCore.Ocr(inFile, outType)
        while core.isRunning():
            time.sleep(5)
            print(core.currentTask + ': ' + core.fileName)
            core.updateTick()
        exit()


def printHelpTextAndExitIfNeeded(args):
    # If the wrong number of args are given, show help and exit
    argCount = len(args)
    if argCount != 3:  # The program, the input file, and the output type
        print("Invalid number of arguments")
        print(helpText)
        exit()

    # If a help argument is given, show help and exit
    for arg in args:
        if arg in helpArgs:
            print(helpText)
            exit()

    if args[2] != 'pdf' and args[2] != 'txt':
        print("Invalid output type: ", args[2])
        print(helpText)
{'fraction_non_alphanumeric': 0.10436969506444514, 'fraction_numerical': 0.0069160641307764855, 'mean_word_length': 2.2602459016393444, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4270645', 'n_tokens_mistral': 1013, 'n_tokens_neox': 992, 'n_words': 336}