mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-05-09 11:14:02 +02: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
2 changed files with 15 additions and 2 deletions
|
|
@ -215,7 +215,7 @@ def parent(self, index):
|
|||
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 @@
|
|||
|
||||
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…
Reference in a new issue