[ocrfeeder] Fix OCR engine list and set Tesseract as default engine
- From: Joaquim Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder] Fix OCR engine list and set Tesseract as default engine
- Date: Sat, 4 Jan 2020 21:17:38 +0000 (UTC)
commit ea6e84d1d8cd27ac6016dc3a29a61e829f1c20c9
Author: scx <scx mail gmail com>
Date: Sun Jan 27 16:34:39 2019 +0100
Fix OCR engine list and set Tesseract as default engine
src/ocrfeeder/feeder/ocrEngines.py | 4 ++--
src/ocrfeeder/studio/widgetPresenter.py | 2 +-
src/ocrfeeder/util/configuration.py | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/src/ocrfeeder/feeder/ocrEngines.py b/src/ocrfeeder/feeder/ocrEngines.py
index c43c8fc..0bbf118 100644
--- a/src/ocrfeeder/feeder/ocrEngines.py
+++ b/src/ocrfeeder/feeder/ocrEngines.py
@@ -212,7 +212,7 @@ class OcrEnginesManager:
if not len(self.ocr_engines):
debug("Warning: no engines found!")
elif not favorite_engine_exists:
- self.configuration_manager.favorite_engine = self.ocr_engines[0][0].name
+ self.configuration_manager.favorite_engine = self.ocr_engines[-1][0].name
engines_needing_update = {'auto': [],
'manual': []}
for engine, path in self.ocr_engines:
@@ -261,7 +261,7 @@ class OcrEnginesManager:
return engine
def getXmlFilesInFolder(self, folder):
- return [os.path.join(folder, file) for file in os.listdir(folder) if file.endswith('.xml')]
+ return [os.path.join(folder, file) for file in sorted(os.listdir(folder)) if file.endswith('.xml')]
def newEngine(self, name, engine_path, arguments,
image_format, failure_string, languages,
diff --git a/src/ocrfeeder/studio/widgetPresenter.py b/src/ocrfeeder/studio/widgetPresenter.py
index 864b207..9e273bf 100644
--- a/src/ocrfeeder/studio/widgetPresenter.py
+++ b/src/ocrfeeder/studio/widgetPresenter.py
@@ -1435,7 +1435,7 @@ class PreferencesDialog(Gtk.Dialog):
try:
index = [engine.name for engine, path in
self.ocr_engines].index(self.configuration_manager.favorite_engine)
except ValueError:
- index = 0
+ index = 0 if len(self.ocr_engines) == 0 else len(self.ocr_engines) - 1
self.engines_combo.set_active(index)
engines_box = Gtk.HBox(spacing = 10)
label = Gtk.Label(_("Favorite _engine:"))
diff --git a/src/ocrfeeder/util/configuration.py b/src/ocrfeeder/util/configuration.py
index 6feb9a1..26c33e5 100644
--- a/src/ocrfeeder/util/configuration.py
+++ b/src/ocrfeeder/util/configuration.py
@@ -114,7 +114,7 @@ class ConfigurationManager(object):
UNPAPER_USE_BLACK_FILTER: True,
UNPAPER_NOISE_FILTER_INTENSITY: 'auto',
UNPAPER_GRAY_FILTER_SIZE: 'auto',
- FAVORITE_ENGINE: 'ocrad',
+ FAVORITE_ENGINE: 'tesseract',
IMPROVE_COLUMN_DETECTION: True,
COLUMN_MIN_WIDTH: 'auto',
CLEAN_TEXT: True,
@@ -172,7 +172,7 @@ class ConfigurationManager(object):
language_argument = language_argument,
version = version)
existing_engines.append(engine)
- return existing_engines
+ return sorted(existing_engines, key=lambda x: x.name, reverse=False)
def setConf(self, conf_key, value):
ConfigurationManager.conf[conf_key] = value
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]