1 from __future__ import absolute_import
2 __copyright__ = "Copyright (C) 2013 David Braam - Released under terms of the AGPLv3 License"
7 __all__ = ['getPathForResource', 'getPathForImage', 'getPathForMesh']
10 if sys.platform.startswith('darwin'):
11 if hasattr(sys, 'frozen'):
12 from Foundation import *
13 resourceBasePath = NSBundle.mainBundle().resourcePath()
15 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
17 if hasattr(sys, 'frozen'):
18 resourceBasePath = os.path.join(os.path.dirname(__file__), "../../resources")
20 resourceBasePath = os.path.join(os.path.dirname(__file__), "../resources")
22 def getPathForResource(dir, subdir, resource_name):
23 assert os.path.isdir(dir), "{p} is not a directory".format(p=dir)
24 path = os.path.normpath(os.path.join(dir, subdir, resource_name))
25 assert os.path.isfile(path), "{p} is not a file.".format(p=path)
28 def getPathForImage(name):
29 return getPathForResource(resourceBasePath, 'images', name)
31 def getPathForMesh(name):
32 return getPathForResource(resourceBasePath, 'meshes', name)
34 def getPathForFirmware(name):
35 return getPathForResource(resourceBasePath, 'firmware', name)