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:
Kovid Goyal 2010-01-21 14:00:51 -07:00
parent b3282b3ac5
commit e2580655d1
2 changed files with 15 additions and 2 deletions

View File

@ -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()

View File

@ -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