Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

decode bytecode in string

Florian Brandes422ac9befe37
diff --git a/src/documents/tasks.py b/src/documents/tasks.py
index 61f0b9419..a17b5b57b 100644
--- a/src/documents/tasks.py
+++ b/src/documents/tasks.py
@@ -83,9 +83,10 @@ def barcode_reader(image) -> list:
# Traverse through all the detected barcodes in image
for barcode in detected_barcodes:
if barcode.data:
- barcodes.append(str(barcode.data))
+ decoded_barcode = barcode.data.decode("utf-8")
+ barcodes.append(decoded_barcode)
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
@@ -96,7 +97,7 @@ def scan_file_for_separating_barcodes(filepath: str) -> list:
Returns a list of pagenumbers, which separate the file
"""
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
with tempfile.TemporaryDirectory() as path:
pages_from_path = convert_from_path(filepath, output_folder=path)
diff --git a/src/documents/tests/test_tasks.py b/src/documents/tests/test_tasks.py
index 9ac8c5fae..2f950e28b 100644
--- a/src/documents/tests/test_tasks.py
+++ b/src/documents/tests/test_tasks.py
@@ -98,7 +98,7 @@ class TestTasks(DirectoriesMixin, TestCase):
"patch-code-t.pbm",
)
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])
def test_barcode_reader2(self):