scanbook/cli.py
def main(bookname, filenames, threshold, no_cleanup, verbose):
    """
    Processes image files and turns them into a black-and-white PDF for easy
    reading. BOOKNAME is used to name the output PDF.

    Examples:

        scanbook war-and-peace *.jpg

        scanbook --threshold 27 war-and-peace *.jpg

        scanbook --no-cleanup --verbose --threshold 9 war-and-peace *.jpg
    """
    folder = f'__{bookname}'

    # Make sure the output folder exists
    if not os.path.exists(folder):
        if verbose:
            click.echo(f'Folder {folder} doesn\'t exist, creating it')
        os.makedirs(folder)

    # Process the images
    for file in filenames:
        if verbose:
            click.echo(f'Processing {file}')
        scanbook.process(file, folder, threshold)

    # Convert them to PDF
    if verbose:
        click.echo(f'Converting to PDF')
    scanbook.make_pdf(folder, bookname, verbose)

    # And clean up
    if not no_cleanup:
        if verbose:
            click.echo(f'Removing {folder}/')
        subprocess.run(['rm', '-rf', f'{folder}/'])

    Processes image files and turns them into a black-and-white PDF for easy
    reading. BOOKNAME is used to name the output PDF.

    Examples:

        scanbook war-and-peace *.jpg

        scanbook --threshold 27 war-and-peace *.jpg

        scanbook --no-cleanup --verbose --threshold 9 war-and-peace *.jpg
    
Processes image files and turns them into a black-and-white PDF for easy
reading. BOOKNAME is used to name the output PDF.
Processes image files and turns them into a black - and - white PDF for easy reading . BOOKNAME is used to name the output PDF .
def main(bookname, filenames, threshold, no_cleanup, verbose):
    folder = f'__{bookname}'
    if not os.path.exists(folder):
        if verbose:
            click.echo(f'Folder {folder} doesn\'t exist, creating it')
        os.makedirs(folder)
    for file in filenames:
        if verbose:
            click.echo(f'Processing {file}')
        scanbook.process(file, folder, threshold)
    if verbose:
        click.echo(f'Converting to PDF')
    scanbook.make_pdf(folder, bookname, verbose)
    if not no_cleanup:
        if verbose:
            click.echo(f'Removing {folder}/')
        subprocess.run(['rm', '-rf', f'{folder}/'])
def main ( bookname , filenames , threshold , no_cleanup , verbose ) : folder = f'__{bookname}' if not os . path . exists ( folder ) : if verbose : click . echo ( f'Folder {folder} doesn\'t exist, creating it' ) os . makedirs ( folder ) for file in filenames : if verbose : click . echo ( f'Processing {file}' ) scanbook . process ( file , folder , threshold ) if verbose : click . echo ( f'Converting to PDF' ) scanbook . make_pdf ( folder , bookname , verbose ) if not no_cleanup : if verbose : click . echo ( f'Removing {folder}/' ) subprocess . run ( [ 'rm' , '-rf' , f'{folder}/' ] )
Processes image files and turns them into a black-and-white PDF for easy
reading.
Processes image files and turns them into a black - and - white PDF for easy reading .
"""
    Processes image files and turns them into a black-and-white PDF for easy
    reading. BOOKNAME is used to name the output PDF.

    Examples:

        scanbook war-and-peace *.jpg

        scanbook --threshold 27 war-and-peace *.jpg

        scanbook --no-cleanup --verbose --threshold 9 war-and-peace *.jpg
    """ # Make sure the output folder exists # Process the images # Convert them to PDF # And clean up
bookname
filenames
threshold
no_cleanup
verbose
examples
scanbook war-and-peace *.jpg

-threshold 27 war-and-peace *.jpg

-no-cleanup --verbose --threshold 9 war-and-peace *.jpg
scanbook war - and - peace * . jpg - threshold 27 war - and - peace * . jpg - no - cleanup -- verbose -- threshold 9 war - and - peace * . jpg