[ocrfeeder/iso_codes: 2/2] util: Change how ISO_CODES_PATH is set
- From: Joaquim Rocha <jrocha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ocrfeeder/iso_codes: 2/2] util: Change how ISO_CODES_PATH is set
- Date: Sat, 18 Apr 2020 20:30:34 +0000 (UTC)
commit 2ecf58a3c93e569194acedca2e2c9d38caea969e
Author: Joaquim Rocha <me joaquimrocha com>
Date: Sat Apr 18 22:27:27 2020 +0200
util: Change how ISO_CODES_PATH is set
The ISO_CODES_PATH was hardcoded, and this means that the path may not
be the correct one in some systems. Therefore, these changes allow to
set an ISO_CODES_DIR as an environment variable or, in case it is not
set, it looks for the "xml/iso-codes" path within the system's data
dirs.
src/ocrfeeder/util/constants.py.in | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/src/ocrfeeder/util/constants.py.in b/src/ocrfeeder/util/constants.py.in
index ae4ae65..dc00b4c 100644
--- a/src/ocrfeeder/util/constants.py.in
+++ b/src/ocrfeeder/util/constants.py.in
@@ -93,7 +93,14 @@ OCRFEEDER_SPELLCHECKER_UI = os.path.join(RESOURCES_DIR, 'spell-checker.ui')
OCRFEEDER_MENUBAR_UI = os.path.join(RESOURCES_DIR, 'menubar.ui')
# ISO-codes location
-ISO_CODES_PATH = '/usr/share/xml/iso-codes/'
+iso_codes_dir = os.environ.get('ISO_CODES_DIR')
+if iso_codes_dir is None:
+ for dir in GLib.get_system_data_dirs():
+ iso_codes_dir = os.path.join(dir, 'xml', 'iso-codes')
+ if os.path.isdir(iso_codes_dir):
+ break
+
+ISO_CODES_PATH = iso_codes_dir
APP_ID = 'org.gnome.OCRFeeder'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]