PKYqJdbackup/__init__.py""" Sweet docstring here. """ __version__ = "0.0.1" import shutil def arc_pack(target_path: str, archive_path: str, format='bztar') -> bool: """ Compress directory at directory_path to archive at archive_path. :param target_path: Path to the directory to compress/archive. :param archive_path: Path to the created archive. :param compression_format: The compression format to use. :return: True if successful else False. """ try: shutil.make_archive(base_name=archive_path, root_dir=target_path, format=format) resp = True except Exception as e: print(e) resp = False finally: return resp if resp else False def arc_unpack(target_path: str, extract_dir: str = None, format: str = None) -> bool: """ Extract archive at archive_path to extracted_path. :param target_path: Path to the archive to extract. :param extract_dir: Path to the extracted archive. :param format: Format of archive to extract :return: True if successful else False. """ try: shutil.unpack_archive(filename=target_path, extract_dir=extract_dir, format=format) resp = True except Exception as e: print(e) resp = False finally: return resp PK9XqJѳggbackup/tests.pyimport shutil import unittest.mock as mock from . import arc_pack, arc_unpack @mock.patch("shutil.make_archive") def test_arc_pack_calls_make_archive(mocked_make_archive): arc_pack('t1', 't2') shutil.make_archive.assert_called() @mock.patch("shutil.make_archive") def test_arc_pack_fails_gracefully(mocked_make_archive): shutil.make_archive.side_effect = OSError('File(s) not available!') assert arc_pack('t1', 't2') is False @mock.patch("shutil.unpack_archive") def test_arc_unpack_calls_unpack_archive(mocked_unpack_archive): arc_unpack('t1') shutil.unpack_archive.assert_called() PK!H|&Ubbackup-0.0.1.dist-info/WHEEL HM K-*ϳR03rOK-J,/RH,Q034 /, (-JLR()*M ILR(4KM̫#DPK!H_backup-0.0.1.dist-info/METADATAE0E|@XұQGd$$^A-{J!KŚUhIs여JPD b oAS NNGeIޅr6S#Ǿ 4+<8E}KuNm]o/E…ӛvf:uyeS]^wY1PK!Hd&i<\backup-0.0.1.dist-info/RECORDuN0 2 CIl@E2^]e/_YT<Bϔ"NWBFΟRAYH+e&[P%uPM[ߣ\gbUS5\x WCbge5@$Qx \w;=6>g{sby9o꾽#境~qjFj!5/=R5arJK(f +#ZsDzs31~ b7PKYqJdbackup/__init__.pyPK9XqJѳggbackup/tests.pyPK!H|&UbTbackup-0.0.1.dist-info/WHEELPK!H_backup-0.0.1.dist-info/METADATAPK!Hd&i<\ backup-0.0.1.dist-info/RECORDPK_