def generate_tree_path(fileDigest, depth):
        """Generate a relative path from the given fileDigest
            relative path has a numbers of directories levels according to @depth

         Args:
            fileDigest -- digest for which the relative path will be generate
            depth -- number of levels to use in relative path generation
         Returns:
            relative path for the given digest
        """
        if(depth < 0):
            raise Exception("depth level can not be negative")
        if(os.path.split(fileDigest)[1] != fileDigest):
            raise Exception("fileDigest cannot contain path separator")

        # calculate min length for the given depth (2^1+2^2+...+2^depth+ 1)
        min = (2**(depth + 1)) - 1
        if(len(fileDigest) < min):
            raise Exception("fileDigest too short for the given depth")

        path = ""
        index = 0
        for p in range(1, depth + 1):
            jump = 2**p
            path = os.path.join(path, fileDigest[index:index + jump])
            index += jump
        path = os.path.join(path, fileDigest[index:])
        return path
def generate_tree_path ( fileDigest , depth ) : if ( depth < 0 ) : raise Exception ( "depth level can not be negative" ) if ( os . path . split ( fileDigest ) [ 1 ] != fileDigest ) : raise Exception ( "fileDigest cannot contain path separator" ) min = ( 2 ** ( depth + 1 ) ) - 1 if ( len ( fileDigest ) < min ) : raise Exception ( "fileDigest too short for the given depth" ) path = "" index = 0 for p in range ( 1 , depth + 1 ) : jump = 2 ** p path = os . path . join ( path , fileDigest [ index : index + jump ] ) index += jump path = os . path . join ( path , fileDigest [ index : ] ) return path
Generate a relative path from the given fileDigest
            relative path has a numbers of directories levels according to @depth

         Args:
            fileDigest -- digest for which the relative path will be generate
            depth -- number of levels to use in relative path generation
         Returns:
            relative path for the given digest