[issue13477] tarfile module should have a command line

STINNER Victor report at bugs.python.org
Fri Mar 8 03:26:56 CET 2013


STINNER Victor added the comment:

+    parser.add_argument('--gz', '--gunzip', '--gzip', '--tgz', '-z', 
+                        '--ungzip', action = 'store_true', 
+                        help = 'gz compression')
+    parser.add_argument('--bz2', '--bzip2', '--tbz2', '--tbz', '--tb2',
+                        action = 'store_true', help = 'bz2 compression')
+    parser.add_argument('--xz', '--lzma', action = 'store_true',
+                        help = 'xz compression')

Do we really need so much names for the same option? Where do these names come from?

--

main() should exit after extract and create to only do one operation and don't always display the usage.

It would be better to not duplicate the list of options and use parser.print_help() instead of sys.stdout.write(__doc__).

Some consistency tests on exclusive options (bzip/gzip/lzma and list/create/extract) would be nice.

--

tar options on Linux:

       -c, --create
       -t, --list
       -x, --extract, --get
       -z, --gzip, --ungzip
       -j, -I, --bzip
       -C, --directory DIRECTORY

For tarfile, I propose to have a shorter list, and try to stay somehow compatible with tar:

       -c, --create
       -t, --list
       -x, --extract
       -z, --gzip
       -j, --bzip
       -C, --directory DIRECTORY

Users of the TAR format usually come from UNIX, so using the same command line options should not be so surprising.

I don't like the idea of an optional argument for --extract: "--extract file1 file2" is usually understood/read as "--extract=filename archive.tar". If you really think that we need to support "only extract some files", it should be a different option. Linux tar command has no such option. I propose to drop this feature (always extract all files).

----------
nosy: +haypo

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13477>
_______________________________________


More information about the Python-bugs-list mailing list