@acquire_lock<EOL><INDENT>@sync_required<EOL>def remove_directory(self, relativePath, removeFromSystem=False):<DEDENT>
<EOL>relativePath = os.path.normpath(relativePath)<EOL>parentDirInfoDict, errorMessage = self.get_parent_directory_info(relativePath)<EOL>assert parentDirInfoDict is not None, errorMessage<EOL>path, name = os.path.split(relativePath)<EOL>if dict.__getitem__(parentDirInfoDict, '<STR_LIT>').get(name, None) is None:<EOL><INDENT>raise Exception("<STR_LIT>"%(name, path))<EOL><DEDENT>if removeFromSystem:<EOL><INDENT>for rp in self.walk_files_relative_path(relativePath=relativePath):<EOL><INDENT>ap = os.path.join(self.__path, relativePath, rp)<EOL>if not os.path.isfile(ap):<EOL><INDENT>continue<EOL><DEDENT>if not os.path.exists(ap):<EOL><INDENT>continue<EOL><DEDENT>if os.path.isfile(ap):<EOL><INDENT>os.remove( ap )<EOL><DEDENT><DEDENT>for rp in self.walk_directories_relative_path(relativePath=relativePath):<EOL><INDENT>ap = os.path.join(self.__path, relativePath, rp)<EOL>if not os.path.isdir(ap):<EOL><INDENT>continue<EOL><DEDENT>if not os.path.exists(ap):<EOL><INDENT>continue<EOL><DEDENT>if not len(os.listdir(ap)):<EOL><INDENT>os.rmdir(ap)<EOL><DEDENT><DEDENT><DEDENT>dict.__getitem__(parentDirInfoDict, '<STR_LIT>').pop(name, None)<EOL>ap = os.path.join(self.__path, relativePath)<EOL>if not os.path.isdir(ap):<EOL><INDENT>if not len(os.listdir(ap)):<EOL><INDENT>os.rmdir(ap)<EOL><DEDENT><DEDENT>self.save()<EOL>
Remove directory from repository.

:Parameters:
    #. relativePath (string): The relative to the repository path of the directory to remove from the repository.
    #. removeFromSystem (boolean): Whether to also remove directory and all files from the system.\n
       Only files saved in the repository will be removed and empty left directories.