def exists(self):
     """
     Checks if the destpath file exists (no dead end) and if destpath, cdslpath and cdsllinkpath are 
     the same file.
     This seems to be more complicated then expected ;-) . So here the current approach:
     Case 1 Not nested:
     If a CDSL is not nested it exists if the sourcepath, the cdsllinkpath and one destpath are exactly 
     the same file and all other destpaths just exist.
     Case 2 nested and hostdependent: 
     A CDSL exists if the resolved path is nested and the sourcepath is a cdsl shared path and the 
     link's destpath is a hostdependent path and one resolved destpaths is the same file then the 
     source and all other destpaths exist.
     Case 3 nested and shared:
     A CDSL exists if the resolved path is nested and the sourcepath is a cdsl hostdependent path and 
     the link's destpath is a cdsl shared path and the resolved destpath exists. Not sure about if 
     also all possible hostdependent sources should exist?. 
     @return: True if this cdsl exists
     @rtype: Boolean
     """
     from comoonics.ComPath import Path
     from comoonics.cdsl import ltrimDir, isHostdependentPath, isSharedPath
     _path=Path()
     _path.pushd(self.getBasePath())
     _exists=False
     _cdslpath=self.getCDSLPath()
     _cdsllinkpath=self.getCDSLLinkPath()
     if not os.path.islink(_cdslpath):
         _path.popd()
         return False
     _cdslreadpath=ltrimDir(os.readlink(_cdslpath))
     if self.isNested():
         # Now we start with all cases that hold for being nested
         if self.isShared():
             # Case 2 (Hostdependent and nested)
             if isHostdependentPath(_cdslreadpath, self.cdslRepository) or not isSharedPath(_cdslreadpath, self.cdslRepository):
                 _path.popd()
                 return False
         elif self.isHostdependent():
             # Case 3 (shared and nested)
             if not isHostdependentPath(_cdslreadpath, self.cdslRepository) or isSharedPath(_cdslreadpath, self.cdslRepository):
                 _path.popd()
                 return False
     _exists_once=False
     _exists_everywhere=True
     for _destpath in self.getDestPaths(): 
         try:
             _exists=os.path.exists(_destpath) and \
                 os.path.samefile(_destpath, _cdslpath) and \
                 os.path.samefile(_destpath, _cdsllinkpath)
             if _exists:
                 _exists_once=True
             if not os.path.exists(_destpath):
                 _exists_everywhere=False
         except OSError:
             _exists_once=False
             _exists_everywhere=False
     _path.popd()
     return _exists_once and _exists_everywhere
    def test0Ltimdir(self):
        from comoonics.cdsl import ltrimDir

        _resultpairs = [
            ["../../../../cluster/shared/hostdependent/shared", "cluster/shared/hostdependent/shared"],
            ["/../../../../cluster/shared/hostdependent/shared", "/../../../../cluster/shared/hostdependent/shared"],
        ]
        for _tmp in _resultpairs:
            self.assertEquals(ltrimDir(_tmp[0]), _tmp[1], "ltrimDir(%s) == %s" % (_tmp[0], _tmp[1]))
 def test0Ltimdir(self):
     from comoonics.cdsl import ltrimDir
     _resultpairs = [[
         "../../../../cluster/shared/hostdependent/shared",
         "cluster/shared/hostdependent/shared"
     ],
                     [
                         "/../../../../cluster/shared/hostdependent/shared",
                         "/../../../../cluster/shared/hostdependent/shared"
                     ]]
     for _tmp in _resultpairs:
         self.assertEquals(ltrimDir(_tmp[0]), _tmp[1],
                           "ltrimDir(%s) == %s" % (_tmp[0], _tmp[1]))
 def exists(self):
     """
     Checks if the destpath file exists (no dead end) and if destpath, cdslpath and cdsllinkpath are 
     the same file.
     This seems to be more complicated then expected ;-) . So here the current approach:
     Case 1 Not nested:
     If a CDSL is not nested it exists if the sourcepath, the cdsllinkpath and one destpath are exactly 
     the same file and all other destpaths just exist.
     Case 2 nested and hostdependent: 
     A CDSL exists if the resolved path is nested and the sourcepath is a cdsl shared path and the 
     link's destpath is a hostdependent path and one resolved destpaths is the same file then the 
     source and all other destpaths exist.
     Case 3 nested and shared:
     A CDSL exists if the resolved path is nested and the sourcepath is a cdsl hostdependent path and 
     the link's destpath is a cdsl shared path and the resolved destpath exists. Not sure about if 
     also all possible hostdependent sources should exist?. 
     @return: True if this cdsl exists
     @rtype: Boolean
     """
     from comoonics.ComPath import Path
     from comoonics.cdsl import ltrimDir, isHostdependentPath, isSharedPath
     _path = Path()
     _path.pushd(self.getBasePath())
     _exists = False
     _cdslpath = self.getCDSLPath()
     _cdsllinkpath = self.getCDSLLinkPath()
     if not os.path.islink(_cdslpath):
         _path.popd()
         return False
     _cdslreadpath = ltrimDir(os.readlink(_cdslpath))
     if self.isNested():
         # Now we start with all cases that hold for being nested
         if self.isShared():
             # Case 2 (Hostdependent and nested)
             if isHostdependentPath(
                     _cdslreadpath,
                     self.cdslRepository) or not isSharedPath(
                         _cdslreadpath, self.cdslRepository):
                 _path.popd()
                 return False
         elif self.isHostdependent():
             # Case 3 (shared and nested)
             if not isHostdependentPath(
                     _cdslreadpath, self.cdslRepository) or isSharedPath(
                         _cdslreadpath, self.cdslRepository):
                 _path.popd()
                 return False
     _exists_once = False
     _exists_everywhere = True
     for _destpath in self.getDestPaths():
         try:
             _exists=os.path.exists(_destpath) and \
                 os.path.samefile(_destpath, _cdslpath) and \
                 os.path.samefile(_destpath, _cdsllinkpath)
             if _exists:
                 _exists_once = True
             if not os.path.exists(_destpath):
                 _exists_everywhere = False
         except OSError:
             _exists_once = False
             _exists_everywhere = False
     _path.popd()
     return _exists_once and _exists_everywhere