Add useful print statements
This commit is contained in:
parent
341d2232d7
commit
2296aea463
@ -68,8 +68,9 @@ def find_file_noext(directory, prefix="part-hires"):
|
||||
#print(directory, matching_files)
|
||||
return matching_files
|
||||
|
||||
def rotate_and_crop_image(path, image_name, force_rotate=False):
|
||||
def rotate_and_crop_image(path, image_name, force_rotate=False, partnum=""):
|
||||
# Open the image file
|
||||
fprint("Generating thumbnail image for part " + partnum)
|
||||
image_path = path + "/" + image_name
|
||||
with Image.open(image_path) as img:
|
||||
# Check if the image is wider than it is tall
|
||||
@ -89,6 +90,7 @@ def rotate_and_crop_image(path, image_name, force_rotate=False):
|
||||
# Save or display the image
|
||||
img_cropped.save(path + "/" + "thumbnail-" + image_name) # Save the cropped image
|
||||
|
||||
|
||||
def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
tables = []
|
||||
# Extract table data
|
||||
@ -187,10 +189,10 @@ def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
count += 1
|
||||
|
||||
if os.path.exists(output_dir + "/found_part_hires"):
|
||||
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part-hires")[0], force_rotate=(dstype == "Alphawire"))
|
||||
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part-hires")[0], force_rotate=(dstype == "Alphawire"), partnum=partnum)
|
||||
img = weburl + find_file_noext(output_dir, prefix="thumbnail-part-hires")[0]
|
||||
elif len(find_file_noext(output_dir, prefix="part")) > 0:
|
||||
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part")[0], force_rotate=(dstype == "Alphawire"))
|
||||
rotate_and_crop_image(output_dir, find_file_noext(output_dir, prefix="part")[0], force_rotate=(dstype == "Alphawire"), partnum=partnum)
|
||||
img = weburl + find_file_noext(output_dir, prefix="thumbnail-part")[0]
|
||||
else:
|
||||
img = None
|
||||
@ -409,6 +411,7 @@ def parse(filename, output_dir, partnum, dstype, weburl, extra):
|
||||
with open(output_dir + "/specs.json", 'w') as json_file:
|
||||
json.dump(output_table["fullspecs"], json_file)
|
||||
|
||||
fprint("Datasheet values parsed and saved for " + partnum)
|
||||
#print(json.dumps(output_table, indent=2))
|
||||
touch(output_dir + "/parsed") # mark as parsed
|
||||
return True
|
||||
|
@ -1,5 +1,5 @@
|
||||
# Runtime
|
||||
camelot-py[base]
|
||||
camelot-py[base]==0.9.0
|
||||
opencv-python
|
||||
pypdf2==2.12.1
|
||||
alive-progress
|
||||
|
Loading…
x
Reference in New Issue
Block a user