def test_dir_not_empty_all_images_present(tmp_path): data = data_faker(tmp_path) # Copy all images to dir for f in data.all_names: os.system(f'cp testing/files/{f} {tmp_path}') assert files.dir_not_empty(data)
def _show_page(self) -> 'IO': if not files.dir_not_empty(self._data): print('This is the last page!') self._data.page_num -= 1 return False lscat.show_instant(self._tracker_class, self._data) self._print_page_info()
def test_dir_not_empty_incomplete_dir(tmp_path): data = data_faker(tmp_path) # Copy .koneko and only one image to that dir (tmp_path / '.koneko').touch() os.system(f'cp testing/files/004_祝!!!.jpg {tmp_path}') assert files.dir_not_empty(data) is False
def start(self, main_path: 'Path') -> 'IO': # self._data defined here not in __init__, so that reload() will wipe cache # This has to be taken into account before any attempts to make this a subclass of Data self._data = self._data_class(main_path) if files.dir_not_empty(self._data): self._show_then_fetch() else: self._download_from_scratch()
def _show_page(self) -> 'IO': if not files.dir_not_empty(self._data): printer.print_bottom('This is the last page!') self._data.page_num -= 1 return False self.scroll_or_show() self._report()
def init_download(data: 'data.<class>', tracker: 'lscat.<class>') -> 'IO': """Download the illustrations of one page and rename them.""" if files.dir_not_empty(data): return True if data.page_num == 1: print('Cache is outdated, reloading...') if data.download_path.is_dir(): rmtree(data.download_path) if data.all_urls: _async_download_rename(data, tracker) if isinstance(data, UserData): save_number_of_artists(data)
def _verify_up_to_date(self): if files.dir_not_empty(self._data): return True files.remove_dir_if_exist(self._data) download.init_download(self._data, self._tracker_class(self._data))
def _verify_up_to_date(self) -> 'IO': if files.dir_not_empty(self._data): return True files.remove_dir_if_exist(self._data) self._download_save_images()
def test_dir_not_empty_dir_exists_but_empty(tmp_path): """Test dir exists but is empty""" data = data_faker(tmp_path) tmp_path.mkdir(exist_ok=True) assert files.dir_not_empty(data) is False