Skip to content

Commit 69c3fed

Browse files
GH-55: Force overwrite if the skip flag is not set (GH-56)
* Overwrite the existing files by default * Replace the `filter` with list comprehension * Add unit test for checking the overwrite
1 parent b1105c0 commit 69c3fed

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

src/thumbnails/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from .thumbnail import ThumbnailVTT
2323
from .thumbnail import register_thumbnail
2424

25-
__version__ = "0.1.3"
25+
__version__ = "0.1.4"
2626
__all__ = (
2727
"Generator",
2828
"Thumbnail",

src/thumbnails/generator.py

+2-9
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import os
55
import re
66

7-
import click
8-
97
from .constants import DEFAULT_BASE
108
from .constants import DEFAULT_COMPRESS
119
from .constants import DEFAULT_FORMAT
@@ -48,13 +46,8 @@ def worker(video, fmt, base, skip, output):
4846
thumbnail.generate()
4947

5048
def generate(self):
51-
self.inputs = dict(zip(
52-
map(lambda i: metadata_path(i, self.output, self.format), self.inputs),
53-
filter(lambda i: re.match(r"^.*\.(?:(?!png|vtt|json).)+$", i), self.inputs),
54-
))
55-
56-
if not self.skip and any(map(os.path.exists, self.inputs.keys())):
57-
self.skip = not click.confirm("Do you want to overwrite already existing files?")
49+
self.inputs = [file for file in self.inputs if re.match(r"^.*\.(?:(?!png|vtt|json).)+$", file)]
50+
self.inputs = dict(zip(map(lambda i: metadata_path(i, self.output, self.format), self.inputs), self.inputs))
5851

5952
with concurrent.futures.ThreadPoolExecutor() as executor:
6053
videos = executor.map(

tests/test_cli.py

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ def test_cli_only_files(tmp_media):
3737
assert os.path.exists(os.path.join(tmp_media, "avi", "video.vtt"))
3838

3939

40+
def test_cli_overwrite_files(tmp_media):
41+
test_cli_only_files(tmp_media)
42+
test_cli_only_files(tmp_media)
43+
44+
4045
def test_cli_only_directories(tmp_media):
4146
execute_cli(
4247
os.path.join(tmp_media, "avi"),

0 commit comments

Comments
 (0)