|
|
@ -30,6 +30,9 @@ import pkg_resources
|
|
|
|
from keymapper.logger import logger
|
|
|
|
from keymapper.logger import logger
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logged = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def get_data_path(filename=''):
|
|
|
|
def get_data_path(filename=''):
|
|
|
|
"""Depending on the installation prefix, return the data dir.
|
|
|
|
"""Depending on the installation prefix, return the data dir.
|
|
|
|
|
|
|
|
|
|
|
@ -58,8 +61,10 @@ def get_data_path(filename=''):
|
|
|
|
'/usr/share/key-mapper'
|
|
|
|
'/usr/share/key-mapper'
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
print('source_path', source_path)
|
|
|
|
global logged
|
|
|
|
if '/site-packages' not in source_path:
|
|
|
|
data_path = None
|
|
|
|
|
|
|
|
# python3.8/dist-packages python3.7/site-packages, /usr/share, /usr/local/share, endless options
|
|
|
|
|
|
|
|
if '-packages' not in source_path and 'python' not in source_path:
|
|
|
|
# probably installed with -e, running from the cloned git source
|
|
|
|
# probably installed with -e, running from the cloned git source
|
|
|
|
data_path = os.path.join(source_path, 'data')
|
|
|
|
data_path = os.path.join(source_path, 'data')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
@ -68,6 +73,12 @@ def get_data_path(filename=''):
|
|
|
|
if os.path.exists(candidate):
|
|
|
|
if os.path.exists(candidate):
|
|
|
|
data_path = candidate
|
|
|
|
data_path = candidate
|
|
|
|
break
|
|
|
|
break
|
|
|
|
logger.error('Could not find the application data')
|
|
|
|
if data_path is None:
|
|
|
|
|
|
|
|
logger.error('Could not find the application data')
|
|
|
|
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not logged:
|
|
|
|
|
|
|
|
logger.debug('Found data at "%s"', data_path)
|
|
|
|
|
|
|
|
logged = True
|
|
|
|
|
|
|
|
|
|
|
|
return os.path.join(data_path, filename)
|
|
|
|
return os.path.join(data_path, filename)
|
|
|
|