]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
decode bytecode in string
authorFlorian Brandes <florian.brandes@posteo.de>
Tue, 29 Mar 2022 16:05:20 +0000 (18:05 +0200)
committerFlorian Brandes <florian.brandes@posteo.de>
Thu, 7 Apr 2022 09:14:29 +0000 (11:14 +0200)
Signed-off-by: Florian Brandes <florian.brandes@posteo.de>
src/documents/tasks.py
src/documents/tests/test_tasks.py

index 61f0b9419953881751acfa58b754484a92275af6..a17b5b57bf4fa66c50a99d4cf46c40c7187eb3c2 100644 (file)
@@ -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)
index 9ac8c5fae27d07e2346dc761650c112228599b41..2f950e28bffa4912e28c68cdf6031ed69e4c8be7 100644 (file)
@@ -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):