2 from __future__ import absolute_import
6 __all__ = ['getPathForResource', 'getPathForImage', 'getPathForMesh']
9 if sys.platform.startswith('darwin'):
10 if hasattr(sys, 'frozen'):
11 from Foundation import *
12 resourceBasePath = NSBundle.mainBundle().resourcePath()
14 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
16 if hasattr(sys, 'frozen'):
17 resourceBasePath = os.path.join(os.path.dirname(__file__), "../../resources")
19 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
21 def getPathForResource(dir, subdir, resource_name):
22 assert os.path.isdir(dir), "{p} is not a directory".format(p=dir)
23 path = os.path.normpath(os.path.join(dir, subdir, resource_name))
24 assert os.path.isfile(path), "{p} is not a file.".format(p=path)
27 def getPathForImage(name):
28 return getPathForResource(resourceBasePath, 'images', name)
30 def getPathForMesh(name):
31 return getPathForResource(resourceBasePath, 'meshes', name)
33 def getPathForFirmware(name):
34 return getPathForResource(resourceBasePath, 'firmware', name)