Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions patoolib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ def extract_archive(
program: str | None = None,
interactive: bool = True,
password: str | None = None,
format: str | None = None,
) -> str:
"""Extract an archive file.

Expand Down Expand Up @@ -1187,6 +1188,8 @@ def extract_archive(
Note that the password might be written to logs that keep track of your command line
history. If an archive program does not support passwords this option is ignored by patool.
:type password: str or None
:param format: If given, use this archive format instead of auto-detection.
:type format: str or None
:raise patoolib.PatoolError: If an archive does not exist or is not a regular file, or on errors while
extracting.
:return: The directory where the archive has been extracted.
Expand All @@ -1202,6 +1205,7 @@ def extract_archive(
outdir=outdir,
program=program,
password=password,
format=format,
)


Expand All @@ -1211,6 +1215,7 @@ def list_archive(
program: str | None = None,
interactive: bool = True,
password: str | None = None,
format: str | None = None,
) -> None:
"""List given archive.

Expand All @@ -1235,6 +1240,8 @@ def list_archive(
Note that the password might be written to logs that keep track of your command line
history. If an archive program does not support passwords this option is ignored by patool.
:type password: str or None
:param format: If given, use this archive format instead of auto-detection.
:type format: str or None
:raise patoolib.PatoolError: If an archive does not exist or is not a regular file, or on errors while
listing.
:return: None
Expand All @@ -1251,6 +1258,7 @@ def list_archive(
interactive=interactive,
program=program,
password=password,
format=format,
)


Expand All @@ -1260,6 +1268,7 @@ def test_archive(
program: str | None = None,
interactive: bool = True,
password: str | None = None,
format: str | None = None,
) -> None:
"""Test given archive.

Expand All @@ -1284,6 +1293,8 @@ def test_archive(
Note that the password might be written to logs that keep track of your command line
history. If an archive program does not support passwords this option is ignored by patool.
:type password: str or None
:param format: If given, use this archive format instead of auto-detection.
:type format: str or None
:raise patoolib.PatoolError: If an archive does not exist or is not a regular file, or on errors while
testing.
:return: None
Expand All @@ -1299,6 +1310,7 @@ def test_archive(
interactive=interactive,
program=program,
password=password,
format=format,
)
if verbosity >= 0:
log.log_info("... tested ok.")
Expand All @@ -1312,6 +1324,7 @@ def create_archive(
program: str | None = None,
interactive: bool = True,
password: str | None = None,
format: str | None = None,
) -> None:
"""Create given archive with given files.

Expand Down Expand Up @@ -1339,6 +1352,8 @@ def create_archive(
Note that the password might be written to logs that keep track of your command line
history. If an archive program does not support passwords this option is ignored by patool.
:type password: str or None
:param format: If given, use this archive format instead of auto-detection.
:type format: str or None
:raise patoolib.PatoolError: on errors while creating the archive
:return: None
:rtype: None
Expand All @@ -1354,6 +1369,7 @@ def create_archive(
interactive=interactive,
program=program,
password=password,
format=format,
)
if verbosity >= 0:
log.log_info(f"... {archive} created.")
Expand Down
8 changes: 8 additions & 0 deletions patoolib/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def run_extract(args: argparse.Namespace) -> int:
interactive=args.interactive,
outdir=args.outdir,
password=args.password,
format=args.format,
)
except PatoolError as msg:
log_error(f"error extracting {archive}: {msg}")
Expand All @@ -74,6 +75,7 @@ def run_list(args: argparse.Namespace) -> int:
verbosity=verbosity,
interactive=args.interactive,
password=args.password,
format=args.format,
)
except PatoolError as msg:
log_error(f"error listing {archive}: {msg}")
Expand All @@ -91,6 +93,7 @@ def run_test(args: argparse.Namespace) -> int:
verbosity=args.verbosity,
interactive=args.interactive,
password=args.password,
format=args.format,
)
except PatoolError as msg:
log_error(f"error testing {archive}: {msg}")
Expand All @@ -108,6 +111,7 @@ def run_create(args: argparse.Namespace) -> int:
verbosity=args.verbosity,
interactive=args.interactive,
password=args.password,
format=args.format,
)
except PatoolError as msg:
log_error(f"error creating {args.archive}: {msg}")
Expand Down Expand Up @@ -236,16 +240,19 @@ def create_argparser() -> argparse.ArgumentParser:
)
parser_extract.add_argument('--outdir', help="output directory to extract to")
parser_extract.add_argument('--password', help="password for encrypted files")
parser_extract.add_argument('--format', help="archive format (e.g., 7z, tar, rar) - auto detected if not provided")
parser_extract.add_argument('archive', nargs='+', help="an archive file")
# list
parser_list = subparsers.add_parser(
'list', help='list members or one or more archives'
)
parser_list.add_argument('--password', help="password for encrypted files")
parser_list.add_argument('--format', help="archive format (e.g., 7z, tar, rar) - auto detected if not provided")
parser_list.add_argument('archive', nargs='+', help="an archive file")
# create
parser_create = subparsers.add_parser('create', help='create an archive')
parser_create.add_argument('--password', help="password to encrypt files")
parser_create.add_argument('--format', help="archive format (e.g., 7z, tar, rar) - auto detected if not provided")
parser_create.add_argument(
'archive',
help="the archive file; the file extension determines the archive program",
Expand All @@ -258,6 +265,7 @@ def create_argparser() -> argparse.ArgumentParser:
# test
parser_test = subparsers.add_parser('test', help='test an archive')
parser_test.add_argument('--password', help="password for encrypted files")
parser_test.add_argument('--format', help="archive format (e.g., 7z, tar, rar) - auto detected if not provided")
parser_test.add_argument('archive', nargs='+', help='an archive file')
# repack
parser_repack = subparsers.add_parser(
Expand Down