mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
decode bytecode in string
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
This commit is contained in:
parent
793f641af6
commit
422ac9befe
@ -83,9 +83,10 @@ def barcode_reader(image) -> list:
|
|||||||
# Traverse through all the detected barcodes in image
|
# Traverse through all the detected barcodes in image
|
||||||
for barcode in detected_barcodes:
|
for barcode in detected_barcodes:
|
||||||
if barcode.data:
|
if barcode.data:
|
||||||
barcodes.append(str(barcode.data))
|
decoded_barcode = barcode.data.decode("utf-8")
|
||||||
|
barcodes.append(decoded_barcode)
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Barcode of type {str(barcode.type)} found: {str(barcode.data)}",
|
f"Barcode of type {str(barcode.type)} found: {decoded_barcode}",
|
||||||
)
|
)
|
||||||
return barcodes
|
return barcodes
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ def scan_file_for_separating_barcodes(filepath: str) -> list:
|
|||||||
Returns a list of pagenumbers, which separate the file
|
Returns a list of pagenumbers, which separate the file
|
||||||
"""
|
"""
|
||||||
separator_page_numbers = []
|
separator_page_numbers = []
|
||||||
separator_barcode = "b'" + str(settings.CONSUMER_BARCODE_STRING) + "'"
|
separator_barcode = str(settings.CONSUMER_BARCODE_STRING)
|
||||||
# use a temporary directory in case the file os too big to handle in memory
|
# use a temporary directory in case the file os too big to handle in memory
|
||||||
with tempfile.TemporaryDirectory() as path:
|
with tempfile.TemporaryDirectory() as path:
|
||||||
pages_from_path = convert_from_path(filepath, output_folder=path)
|
pages_from_path = convert_from_path(filepath, output_folder=path)
|
||||||
|
@ -98,7 +98,7 @@ class TestTasks(DirectoriesMixin, TestCase):
|
|||||||
"patch-code-t.pbm",
|
"patch-code-t.pbm",
|
||||||
)
|
)
|
||||||
img = Image.open(test_file)
|
img = Image.open(test_file)
|
||||||
separator_barcode = "b'" + str(settings.CONSUMER_BARCODE_STRING) + "'"
|
separator_barcode = str(settings.CONSUMER_BARCODE_STRING)
|
||||||
self.assertEqual(tasks.barcode_reader(img), [separator_barcode])
|
self.assertEqual(tasks.barcode_reader(img), [separator_barcode])
|
||||||
|
|
||||||
def test_barcode_reader2(self):
|
def test_barcode_reader2(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user