Skip to content

Commit fe7f418

Browse files
sohei-tclaude
andcommitted
Apply code formatting with black and isort
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent a8f5d66 commit fe7f418

18 files changed

Lines changed: 281 additions & 173 deletions

File tree

audio-extractor/audio_extractor.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ def extract_audio(
7373
command = [
7474
ffmpeg_path,
7575
"-y",
76-
"-i", str(input_file),
76+
"-i",
77+
str(input_file),
7778
"-vn",
78-
"-acodec", "libmp3lame",
79+
"-acodec",
80+
"libmp3lame",
7981
]
8082

8183
if bitrate:
@@ -126,13 +128,15 @@ def main():
126128
help="入力ファイルまたはディレクトリ",
127129
)
128130
parser.add_argument(
129-
"-i", "--input-dir",
131+
"-i",
132+
"--input-dir",
130133
type=Path,
131134
default=None,
132135
help="入力ディレクトリ(位置引数がない場合に使用)",
133136
)
134137
parser.add_argument(
135-
"-o", "--output-dir",
138+
"-o",
139+
"--output-dir",
136140
type=Path,
137141
default=None,
138142
help="出力ディレクトリ(デフォルト: 入力と同じ場所)",

audio-remover/audio_remover.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ def remove_audio(
6868
command = [
6969
ffmpeg_path,
7070
"-y",
71-
"-i", str(input_file),
71+
"-i",
72+
str(input_file),
7273
"-an", # 音声トラックを除去
73-
"-c:v", "copy", # 映像は再エンコードせずコピー
74+
"-c:v",
75+
"copy", # 映像は再エンコードせずコピー
7476
str(output_file),
7577
]
7678

@@ -128,13 +130,15 @@ def main():
128130
help="入力ファイルまたはディレクトリ",
129131
)
130132
parser.add_argument(
131-
"-i", "--input-dir",
133+
"-i",
134+
"--input-dir",
132135
type=Path,
133136
default=None,
134137
help="入力ディレクトリ",
135138
)
136139
parser.add_argument(
137-
"-o", "--output-dir",
140+
"-o",
141+
"--output-dir",
138142
type=Path,
139143
default=None,
140144
help="出力ディレクトリ(デフォルト: 入力と同じ場所)",
@@ -218,7 +222,9 @@ def main():
218222

219223
# 入力と出力が同じ場合はスキップ
220224
if output_file.resolve() == video_file.resolve():
221-
print(" エラー: 入力と出力が同じファイルです。--suffix または --prefix を指定してください")
225+
print(
226+
" エラー: 入力と出力が同じファイルです。--suffix または --prefix を指定してください"
227+
)
222228
fail_count += 1
223229
continue
224230

face-cropper/face_cropper.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def crop_face(
6666
new_w = min(w + 2 * margin_w, image.shape[1] - new_x)
6767
new_h = min(h + 2 * margin_h, image.shape[0] - new_y)
6868

69-
return image[new_y:new_y + new_h, new_x:new_x + new_w]
69+
return image[new_y : new_y + new_h, new_x : new_x + new_w]
7070

7171

7272
def resize_to_square(
@@ -87,14 +87,14 @@ def resize_to_square(
8787
new_height = int(size / aspect_ratio)
8888
resized = cv2.resize(image, (new_width, new_height))
8989
y_offset = (size - new_height) // 2
90-
output[y_offset:y_offset + new_height, :] = resized
90+
output[y_offset : y_offset + new_height, :] = resized
9191
else:
9292
# 縦長または正方形
9393
new_height = size
9494
new_width = int(size * aspect_ratio)
9595
resized = cv2.resize(image, (new_width, new_height))
9696
x_offset = (size - new_width) // 2
97-
output[:, x_offset:x_offset + new_width] = resized
97+
output[:, x_offset : x_offset + new_width] = resized
9898

9999
return output
100100

@@ -190,13 +190,15 @@ def main():
190190
)
191191

192192
parser.add_argument(
193-
"-i", "--input-dir",
193+
"-i",
194+
"--input-dir",
194195
type=Path,
195196
default=Path.cwd(),
196197
help="入力画像のディレクトリ(デフォルト: カレントディレクトリ)",
197198
)
198199
parser.add_argument(
199-
"-o", "--output-dir",
200+
"-o",
201+
"--output-dir",
200202
type=Path,
201203
default=None,
202204
help="出力ディレクトリ(デフォルト: ./comp)",

face-cropper/slideshow_maker.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ def resize_and_pad(
7373

7474
padded = cv2.copyMakeBorder(
7575
resized,
76-
pad_top, pad_bottom, pad_left, pad_right,
76+
pad_top,
77+
pad_bottom,
78+
pad_left,
79+
pad_right,
7780
cv2.BORDER_CONSTANT,
7881
value=background_color,
7982
)
@@ -158,13 +161,15 @@ def main():
158161
)
159162

160163
parser.add_argument(
161-
"-i", "--input-dir",
164+
"-i",
165+
"--input-dir",
162166
type=Path,
163167
default=Path.cwd(),
164168
help="入力画像のディレクトリ(デフォルト: カレントディレクトリ)",
165169
)
166170
parser.add_argument(
167-
"-o", "--output",
171+
"-o",
172+
"--output",
168173
type=Path,
169174
default=None,
170175
help="出力動画ファイル(デフォルト: slideshow_YYYYMMDD_HHMM.mp4)",

frame-extractor/frame_extractor.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ def parse_time(time_str: str) -> float:
3636
time_str = time_str.strip()
3737

3838
# 秒のみ(例: 90, 90.5)
39-
if re.match(r'^[\d.]+$', time_str):
39+
if re.match(r"^[\d.]+$", time_str):
4040
return float(time_str)
4141

4242
# MM:SS形式(例: 01:30)
43-
match = re.match(r'^(\d+):(\d+(?:\.\d+)?)$', time_str)
43+
match = re.match(r"^(\d+):(\d+(?:\.\d+)?)$", time_str)
4444
if match:
4545
m, s = match.groups()
4646
return int(m) * 60 + float(s)
4747

4848
# HH:MM:SS形式(例: 00:01:30)
49-
match = re.match(r'^(\d+):(\d+):(\d+(?:\.\d+)?)$', time_str)
49+
match = re.match(r"^(\d+):(\d+):(\d+(?:\.\d+)?)$", time_str)
5050
if match:
5151
h, m, s = match.groups()
5252
return int(h) * 3600 + int(m) * 60 + float(s)
@@ -227,13 +227,15 @@ def main():
227227
help="入力ファイルまたはディレクトリ",
228228
)
229229
parser.add_argument(
230-
"-i", "--input-dir",
230+
"-i",
231+
"--input-dir",
231232
type=Path,
232233
default=None,
233234
help="入力ディレクトリ",
234235
)
235236
parser.add_argument(
236-
"-o", "--output-dir",
237+
"-o",
238+
"--output-dir",
237239
type=Path,
238240
default=None,
239241
help="出力ディレクトリ(デフォルト: ./comp)",

image-combiner/image_combiner.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,22 @@ def main():
174174
help="結合する画像ファイル",
175175
)
176176
parser.add_argument(
177-
"-i", "--input-dir",
177+
"-i",
178+
"--input-dir",
178179
type=Path,
179180
default=None,
180181
help="入力ディレクトリ(画像を自動収集)",
181182
)
182183
parser.add_argument(
183-
"-o", "--output",
184+
"-o",
185+
"--output",
184186
type=Path,
185187
default=None,
186188
help="出力ファイル名(デフォルト: combined_image.jpg)",
187189
)
188190
parser.add_argument(
189-
"-v", "--vertical",
191+
"-v",
192+
"--vertical",
190193
action="store_true",
191194
help="縦並びで結合(デフォルト: 横並び)",
192195
)

tests/test_frame_extractor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
"""Tests for frame_extractor module."""
22

3-
import pytest
43
import sys
54
from pathlib import Path
65

6+
import pytest
7+
78
# Add parent directory to path for imports
89
sys.path.insert(0, str(Path(__file__).parent.parent / "frame-extractor"))
910

10-
from frame_extractor import parse_time, parse_range, parse_ranges, format_time
11+
from frame_extractor import format_time, parse_range, parse_ranges, parse_time
1112

1213

1314
class TestParseTime:

tests/test_image_combiner.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
"""Tests for image_combiner module."""
22

3-
import pytest
3+
import os
44
import sys
5+
import tempfile
56
from pathlib import Path
7+
8+
import pytest
69
from PIL import Image
7-
import tempfile
8-
import os
910

1011
# Add parent directory to path for imports
1112
sys.path.insert(0, str(Path(__file__).parent.parent / "image-combiner"))
1213

1314
from image_combiner import (
14-
parse_color,
15-
get_image_files,
1615
combine_images_horizontal,
1716
combine_images_vertical,
17+
get_image_files,
18+
parse_color,
1819
)
1920

2021

tests/test_video_overlay.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
"""Tests for video_overlay module."""
22

3-
import pytest
43
import sys
5-
from pathlib import Path
64
import tempfile
5+
from pathlib import Path
76

7+
import pytest
88

99
# Define functions locally for testing to avoid moviepy dependency
1010
POSITIONS = {
@@ -87,7 +87,9 @@ def test_default_margin(self):
8787
def test_unknown_position_defaults_to_top_right(self):
8888
"""Test that unknown position defaults to top-right."""
8989
x, y = get_position_coords("unknown", (1920, 1080), (100, 100), margin=10)
90-
expected_x, expected_y = get_position_coords("top-right", (1920, 1080), (100, 100), margin=10)
90+
expected_x, expected_y = get_position_coords(
91+
"top-right", (1920, 1080), (100, 100), margin=10
92+
)
9193
assert x == expected_x
9294
assert y == expected_y
9395

tests/test_video_speed_changer.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
"""Tests for video_speed_changer module."""
22

3-
import pytest
43
import sys
5-
from pathlib import Path
64
import tempfile
5+
from pathlib import Path
6+
7+
import pytest
78

89
# Add parent directory to path for imports
910
sys.path.insert(0, str(Path(__file__).parent.parent / "video-speed-changer"))

0 commit comments

Comments
 (0)