1commit cfc05af26b571e9ca09e9c709c0fb8934e9e46dd
2Author: Guillaume Girol <symphorien+git@xlumurb.eu>
3Date: Sat Aug 20 17:48:01 2022 +0200
4
5 Fix finding cuneiform
6
7diff --git a/src/pyocr/cuneiform.py b/src/pyocr/cuneiform.py
8index 2e5b717..35647e2 100644
9--- a/src/pyocr/cuneiform.py
10+++ b/src/pyocr/cuneiform.py
11@@ -25,13 +25,9 @@ from . import builders
12 from .error import CuneiformError
13
14
15-# CHANGE THIS IF CUNEIFORM IS NOT IN YOUR PATH, OR IS NAMED DIFFERENTLY
16-CUNEIFORM_CMD = 'cuneiform'
17+CUNEIFORM_CMD = '@cuneiform@/bin/cuneiform'
18
19-CUNEIFORM_DATA_POSSIBLE_PATHS = [
20- "/usr/local/share/cuneiform",
21- "/usr/share/cuneiform",
22-]
23+CUNEIFORM_DATA_POSSIBLE_PATHS = ['@cuneiform@/share/cuneiform']
24
25 LANGUAGES_LINE_PREFIX = "Supported languages: "
26 LANGUAGES_SPLIT_RE = re.compile("[^a-z]")
27diff --git a/tests/test_cuneiform.py b/tests/test_cuneiform.py
28index b76e93c..266f6b2 100644
29--- a/tests/test_cuneiform.py
30+++ b/tests/test_cuneiform.py
31@@ -21,7 +21,7 @@ class TestCuneiform(BaseTest):
32 # XXX is it useful?
33 which.return_value = True
34 self.assertTrue(cuneiform.is_available())
35- which.assert_called_once_with("cuneiform")
36+ which.assert_called_once_with("@cuneiform@/bin/cuneiform")
37
38 @patch("subprocess.Popen")
39 def test_version(self, popen):
40@@ -54,7 +54,7 @@ class TestCuneiform(BaseTest):
41 self.assertIn("eng", langs)
42 self.assertIn("fra", langs)
43 popen.assert_called_once_with(
44- ["cuneiform", "-l"],
45+ ["@cuneiform@/bin/cuneiform", "-l"],
46 stdout=subprocess.PIPE, stderr=subprocess.STDOUT
47 )
48
49@@ -110,7 +110,7 @@ class TestCuneiformTxt(BaseTest):
50 output = cuneiform.image_to_string(self.image)
51 self.assertEqual(output, self._get_file_content("text").strip())
52 popen.assert_called_once_with(
53- ["cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
54+ ["@cuneiform@/bin/cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
55 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
56 stderr=subprocess.STDOUT
57 )
58@@ -126,7 +126,7 @@ class TestCuneiformTxt(BaseTest):
59 builder=self.builder)
60 self.assertEqual(output, self._get_file_content("text").strip())
61 popen.assert_called_once_with(
62- ["cuneiform", "-l", "fra", "-f", "text", "-o", self.tmp_filename,
63+ ["@cuneiform@/bin/cuneiform", "-l", "fra", "-f", "text", "-o", self.tmp_filename,
64 "-"],
65 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
66 stderr=subprocess.STDOUT
67@@ -143,7 +143,7 @@ class TestCuneiformTxt(BaseTest):
68 builder=self.builder)
69 self.assertEqual(output, self._get_file_content("text").strip())
70 popen.assert_called_once_with(
71- ["cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
72+ ["@cuneiform@/bin/cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
73 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
74 stderr=subprocess.STDOUT
75 )
76@@ -174,7 +174,7 @@ class TestCuneiformTxt(BaseTest):
77 output = cuneiform.image_to_string(image, builder=self.builder)
78 self.assertEqual(output, self._get_file_content("text").strip())
79 popen.assert_called_once_with(
80- ["cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
81+ ["@cuneiform@/bin/cuneiform", "-f", "text", "-o", self.tmp_filename, "-"],
82 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
83 stderr=subprocess.STDOUT
84 )
85@@ -230,7 +230,7 @@ class TestCuneiformWordBox(BaseTest):
86 output = cuneiform.image_to_string(self.image,
87 builder=self.builder)
88 popen.assert_called_once_with(
89- ["cuneiform", "-f", "hocr", "-o", self.tmp_filename, "-"],
90+ ["@cuneiform@/bin/cuneiform", "-f", "hocr", "-o", self.tmp_filename, "-"],
91 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
92 stderr=subprocess.STDOUT
93 )
94@@ -284,7 +284,7 @@ class TestCuneiformLineBox(BaseTest):
95 output = cuneiform.image_to_string(self.image,
96 builder=self.builder)
97 popen.assert_called_once_with(
98- ["cuneiform", "-f", "hocr", "-o", self.tmp_filename, "-"],
99+ ["@cuneiform@/bin/cuneiform", "-f", "hocr", "-o", self.tmp_filename, "-"],
100 stdin=subprocess.PIPE, stdout=subprocess.PIPE,
101 stderr=subprocess.STDOUT