@path_required<EOL><INDENT>def remove_directory(self, relativePath, clean=False, raiseError=True, ntrials=<NUM_LIT:3>):<DEDENT>
assert isinstance(raiseError, bool), "<STR_LIT>"<EOL>assert isinstance(clean, bool), "<STR_LIT>"<EOL>assert isinstance(ntrials, int), "<STR_LIT>"<EOL>assert ntrials><NUM_LIT:0>, "<STR_LIT>"<EOL>relativePath = self.to_repo_relative_path(path=relativePath, split=False)<EOL>parentPath, dirName = os.path.split(relativePath)<EOL>if relativePath == '<STR_LIT>':<EOL><INDENT>return False, "<STR_LIT>"<EOL><DEDENT>if not self.is_repository_directory(relativePath):<EOL><INDENT>return False, "<STR_LIT>"%relativePath<EOL><DEDENT>realPath = os.path.join(self.__path,relativePath)<EOL>if not os.path.isdir(realPath):<EOL><INDENT>error = "<STR_LIT>"<EOL>assert not raiseError, error<EOL>return False, error<EOL><DEDENT>LD =  Locker(filePath=None, lockPass=str(uuid.uuid1()), lockPath=os.path.join(self.__path,parentPath,self.__dirLock))<EOL>acquired, code = LD.acquire_lock()<EOL>if not acquired:<EOL><INDENT>error = "<STR_LIT>"%(code,realPath)<EOL>assert not raiseError, error<EOL>return False, error<EOL><DEDENT>LR =  Locker(filePath=None, lockPass=str(uuid.uuid1()), lockPath=os.path.join(self.__path, self.__repoLock))<EOL>acquired, code = LR.acquire_lock()<EOL>if not acquired:<EOL><INDENT>LD.release_lock()<EOL>m = "<STR_LIT>"%(code,)<EOL>assert raiseError,  Exception(m)<EOL>return False,m<EOL><DEDENT>for _trial in range(ntrials):<EOL><INDENT>error = None<EOL>try:<EOL><INDENT>dirList = self.__get_repository_parent_directory(relativePath=relativePath)<EOL>assert dirList is not None, "<STR_LIT>"%(relativePath,)<EOL>stateBefore = self.get_repository_state(relaPath=parentPath)<EOL>_files = [f for f in dirList if isinstance(f, basestring)]<EOL>_dirs  = [d for d in dirList if isinstance(d, dict)]<EOL>_dirs  = [d for d in dirList if dirName not in d]<EOL>_ = [dirList.pop(<NUM_LIT:0>) for _ in range(len(dirList))]<EOL>dirList.extend(_files)<EOL>dirList.extend(_dirs)<EOL>if clean:<EOL><INDENT>shutil.rmtree(realPath)<EOL><DEDENT>else:<EOL><INDENT>stateAfter = self.get_repository_state(relaPath=parentPath)<EOL>success, errors = self.__clean_before_after(stateBefore=stateBefore, stateAfter=stateAfter, keepNoneEmptyDirectory=True)<EOL>assert success, "<STR_LIT:\n>".join(errors)<EOL><DEDENT><DEDENT>except Exception as err:<EOL><INDENT>error = str(err)<EOL>if self.DEBUG_PRINT_FAILED_TRIALS: print("<STR_LIT>"%(_trial, inspect.stack()[<NUM_LIT:1>][<NUM_LIT:3>], str(error)))<EOL><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if error is None:<EOL><INDENT>_, error = self.__save_repository_pickle_file(lockFirst=False, raiseError=False)<EOL><DEDENT>LD.release_lock()<EOL>LR.release_lock()<EOL>assert error is None or not raiseError, "<STR_LIT>"%(relativePath, ntrials, error,)<EOL>return error is None, error<EOL>
Remove directory from repository tracking.

:Parameters:
    #. relativePath (string): The relative to the repository path of the
       directory to remove from the repository.
    #. clean (boolean): Whether to os remove directory. If False only
       tracked files will be removed along with left empty directories.
    #. raiseError (boolean): Whether to raise encountered error instead
       of returning failure.
    #. ntrials (int): After aquiring all locks, ntrials is the maximum
       number of trials allowed before failing.
       In rare cases, when multiple processes
       are accessing the same repository components, different processes
       can alter repository components between successive lock releases
       of some other process. Bigger number of trials lowers the
       likelyhood of failure due to multiple processes same time
       alteration.

:Returns:
    #. success (boolean): Whether removing the directory was successful.
    #. reason (None, string): Reason why directory was not removed.