mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Development environment: First look for resources in the location pointed to by CALIBRE_DEVELOP_FROM. If not found, use the normal resource location
This commit is contained in:
parent
b3282b3ac5
commit
e2580655d1
@ -215,7 +215,7 @@ class TagsModel(QAbstractItemModel):
|
||||
return QModelIndex()
|
||||
|
||||
child_item = index.internalPointer()
|
||||
parent_item = child_item.parent
|
||||
parent_item = getattr(child_item, 'parent', None)
|
||||
|
||||
if parent_item is self.root_item or parent_item is None:
|
||||
return QModelIndex()
|
||||
|
@ -9,9 +9,22 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import __builtin__, sys, os
|
||||
|
||||
_dev_path = os.environ.get('CALIBRE_DEVELOP_FROM', None)
|
||||
if _dev_path is not None:
|
||||
_dev_path = os.path.join(os.path.abspath(os.path.dirname(_dev_path)), 'resources')
|
||||
if not os.path.exists(_dev_path):
|
||||
_dev_path = None
|
||||
|
||||
def get_path(path, data=False):
|
||||
global _dev_path
|
||||
path = path.replace(os.sep, '/')
|
||||
path = os.path.join(sys.resources_location, *path.split('/'))
|
||||
base = None
|
||||
if _dev_path is not None:
|
||||
if os.path.exists(os.path.join(_dev_path, *path.split('/'))):
|
||||
base = _dev_path
|
||||
if base is None:
|
||||
base = sys.resources_location
|
||||
path = os.path.join(base, *path.split('/'))
|
||||
if data:
|
||||
return open(path, 'rb').read()
|
||||
return path
|
||||
|
Loading…
x
Reference in New Issue
Block a user