Skip to content

Commit 2a6dfdd

Browse files
committed
Use pkg_resources to access default config file
1 parent b6b4036 commit 2a6dfdd

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

arabic_reshaper.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030

3131
from configparser import ConfigParser
3232
from itertools import repeat
33+
from pkg_resources import resource_filename
3334

3435
# ----------------------- Begin: Ligatures Definitions ---------------------- #
3536

@@ -1206,11 +1207,18 @@ def __init__(self, configuration=None, configuration_file=None):
12061207
super(ArabicReshaper, self).__init__()
12071208

12081209
configuration_files = [
1209-
os.path.abspath(
1210-
os.path.join(os.path.dirname(__file__), 'default-config.ini')
1211-
),
1210+
resource_filename(__name__, 'default-config.ini')
12121211
]
12131212

1213+
if not os.path.exists(configuration_files[0]):
1214+
raise Error(
1215+
'Default configuration file {} not found,' +
1216+
' check the module installation.'.format(
1217+
configuration_file,
1218+
)
1219+
)
1220+
1221+
12141222
loaded_from_envvar = False
12151223

12161224
if not configuration_file:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
setup(
77
name = "arabic_reshaper",
88
description = "Reconstruct Arabic sentences to be used in applications that don't support Arabic",
9-
version = '2.0.1',
9+
version = '2.0.2',
1010
platforms = "ALL",
1111
license = "GPL",
1212
packages = ['arabic_reshaper'],

0 commit comments

Comments
 (0)