@path_required<EOL><INDENT>def create_package(self, path=None, name=None, mode=None):<DEDENT>
<EOL>assert mode in (None, '<STR_LIT:w>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'), '<STR_LIT>'%str(mode)<EOL>if mode is None:<EOL><INDENT>mode = '<STR_LIT>'<EOL>mode = '<STR_LIT>'<EOL><DEDENT>if path is None:<EOL><INDENT>root = os.path.split(self.__path)[<NUM_LIT:0>]<EOL><DEDENT>elif path.strip() in ('<STR_LIT>','<STR_LIT:.>'):<EOL><INDENT>root = os.getcwd()<EOL><DEDENT>else:<EOL><INDENT>root = os.path.realpath( os.path.expanduser(path) )<EOL><DEDENT>assert os.path.isdir(root), '<STR_LIT>'%path<EOL>if name is None:<EOL><INDENT>ext = mode.split("<STR_LIT::>")<EOL>if len(ext) == <NUM_LIT:2>:<EOL><INDENT>if len(ext[<NUM_LIT:1>]):<EOL><INDENT>ext = "<STR_LIT:.>"+ext[<NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>ext = '<STR_LIT>'<EOL><DEDENT><DEDENT>else:<EOL><INDENT>ext = '<STR_LIT>'<EOL><DEDENT>name = os.path.split(self.__path)[<NUM_LIT:1>]+ext<EOL><DEDENT>self.save()<EOL>tarfilePath = os.path.join(root, name)<EOL>try:<EOL><INDENT>tarHandler = tarfile.TarFile.open(tarfilePath, mode=mode)<EOL><DEDENT>except Exception as e:<EOL><INDENT>raise Exception("<STR_LIT>"%e)<EOL><DEDENT>for directory in sorted(list(self.walk_directories_relative_path())):<EOL><INDENT>t = tarfile.TarInfo( directory )<EOL>t.type = tarfile.DIRTYPE<EOL>tarHandler.addfile(t)<EOL><DEDENT>for file in self.walk_files_relative_path():<EOL><INDENT>tarHandler.add(os.path.join(self.__path,file), arcname=file)<EOL><DEDENT>tarHandler.add(os.path.join(self.__path,"<STR_LIT>"), arcname="<STR_LIT>")<EOL>tarHandler.close()<EOL>
Create a tar file package of all the repository files and directories.
Only files and directories that are stored in the repository info
are stored in the package tar file.

**N.B. On some systems packaging requires root permissions.**

:Parameters:
    #. path (None, string): The real absolute path where to create the package.
       If None, it will be created in the same directory as the repository
       If '.' or an empty string is passed, the current working directory will be used.
    #. name (None, string): The name to give to the package file
       If None, the package directory name will be used with the appropriate extension added.
    #. mode (None, string): The writing mode of the tarfile.
       If None, automatically the best compression mode will be chose.
       Available modes are ('w', 'w:', 'w:gz', 'w:bz2')