<commit_before>r"""This module contains methods to work with scan devices""" 

import twain
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm
    
def convert_images_to_a4_pdf (images, target_pdf='output.pdf'):  
    """Takes a list of JPG/PNG/BMP images and stores the images to 
       an A4-format PDF with each image as one page."""
       
    c = canvas.Canvas(target_pdf)
    c.setPageCompression(1)
    for image in images:
        c.drawImage(image, 0, 0, 21 * cm, 29.7 * cm)
        c.showPage()
    c.save()

images = ['d:/2014-06-28_104815.bmp' ]
convert_images_to_a4_pdf(images, 'd:/target.pdf')
    
def get_scanner (pickfirst=False):
    """Obtain the name of an available scanner"""
    
    sm = twain.SourceManager(0)
    scanner_name = ''

    if pickfirst:
        scanners = sm.GetSourceList()
        if len(scanners) > 0:
            scanner_name = scanners[0]<commit_msg>Removed temporary test code from b_scan<commit_after>r"""This module contains methods to work with scan devices""" 

import twain
from reportlab.pdfgen import canvas
from reportlab.lib.units import cm
    
def convert_images_to_a4_pdf (images, target_pdf='output.pdf'):  
    """Takes a list of JPG/PNG/BMP images and stores the images to 
       an A4-format PDF with each image as one page."""
       
    c = canvas.Canvas(target_pdf)
    c.setPageCompression(1)
    for image in images:
        c.drawImage(image, 0, 0, 21 * cm, 29.7 * cm)
        c.showPage()
    c.save()
    
def get_scanner (pickfirst=False):
    """Obtain the name of an available scanner"""
    
    sm = twain.SourceManager(0)
    scanner_name = ''

    if pickfirst:
        scanners = sm.GetSourceList()
        if len(scanners) > 0:
            scanner_name = scanners[0]
{'fraction_non_alphanumeric': 0.10407239819004525, 'fraction_numerical': 0.02319004524886878, 'mean_word_length': 2.8373101952277655, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5167249', 'n_tokens_mistral': 608, 'n_tokens_neox': 577, 'n_words': 170}