+try:
+ from gdcmVersion import *
+except:
+ print "gdcmVersion not imported"
+
+def BuildInstallOrPreinstallPath(DirName, FileName = None):
+ # Builds a path to the DirName directory. This should work both when:
+ # - the package is properly installed in which case DirName is a subdir
+ # of the package,
+ # - when in pre-installation mode (basically inside a CVS hierarchy)
+ # in which case DirName and the package itself lie at the same
+ # filesystem level.
+ # In both cases we need to express the full path to DirName relatively
+ # to the path to this __init__.py. For this we rely on __path__ variable.
+ # In order to make sure we got the correct Path, we check for the
+ # existence of FileName if it is setted otherwise for the existence of the
+ # DirName.
+ InstallModePath = os.path.join(__path__[0], DirName + "/")
+ if(FileName):
+ if os.path.isfile(os.path.join(InstallModePath, FileName)):
+ return InstallModePath
+ else:
+ if os.path.isdir(InstallModePath):
+ return InstallModePath
+
+ PreInstallModePath = os.path.join(__path__[0], "..", DirName + "/")
+ if(FileName):
+ if os.path.isfile(os.path.join(PreInstallModePath, FileName)):
+ return PreInstallModePath
+ else:
+ if os.path.isdir(PreInstallModePath):
+ return PreInstallModePath
+ return None
+