Add a little more validation.

master
voussoir 2020-11-20 02:03:29 -08:00
parent 09ac7a4715
commit 26b4a33292
1 changed files with 9 additions and 3 deletions

View File

@ -276,20 +276,26 @@ def rarpar(
): ):
path = pathclass.Path(path) path = pathclass.Path(path)
# Validation ###################################################################################
path.assert_exists() path.assert_exists()
workdir = pathclass.Path(workdir) workdir = pathclass.Path(workdir)
workdir.assert_is_directory() workdir.assert_is_directory()
if moveto: if moveto is not None:
moveto = pathclass.Path(moveto) moveto = pathclass.Path(moveto)
moveto.assert_is_directory() moveto.assert_is_directory()
pathsize = path.size if compression not in [None, 0, 1, 2, 3, 4, 5]:
raise ValueError(f'compression must be 0-5 or None, not {compression}.')
if type(solid) is not bool: if type(solid) is not bool:
raise TypeError(f'solid must be True or False, not {solid}.') raise TypeError(f'solid must be True or False, not {solid}.')
password = normalize_password(password)
pathsize = path.size
volume = normalize_volume(volume, pathsize) volume = normalize_volume(volume, pathsize)
rec = _normalize_percentage(rec) rec = _normalize_percentage(rec)
rev = _normalize_percentage(rev) rev = _normalize_percentage(rev)
@ -320,7 +326,7 @@ def rarpar(
if existing: if existing:
raise RarExists(f'{existing[0]} already exists.') raise RarExists(f'{existing[0]} already exists.')
#### #### # Script building ##############################################################################
script = [] script = []