Skip to content

Commit

Permalink
Refactor kwargs support check
Browse files Browse the repository at this point in the history
  • Loading branch information
mondeja committed Jan 20, 2021
1 parent cc7a829 commit d69a067
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions moviepy/video/fx/rotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,22 @@ def filter(get_frame, t):

# build PIL.rotate kwargs
kwargs, _locals = ({}, locals())
for PIL_rotate_kw_name, support_data in PIL_rotate_kwargs_supported.items():
for PIL_rotate_kw_name, (
kw_name,
supported,
min_version,
) in PIL_rotate_kwargs_supported.items():
# get the value passed to rotate FX from `locals()` dictionary
kwarg_value = _locals[support_data[0]]
kw_value = _locals[kw_name]

if support_data[1]: # if argument supported by PIL version
kwargs[PIL_rotate_kw_name] = kwarg_value
if supported: # if argument supported by PIL version
kwargs[PIL_rotate_kw_name] = kw_value
else:
if kwarg_value is not None: # if not default value
if kw_value is not None: # if not default value
warnings.warn(
f"rotate '{support_data[0]}' argument not supported by your"
f"rotate '{kw_name}' argument not supported by your"
" Pillow version and is being ignored. Minimum Pillow version"
f" required: v{'.'.join(str(n) for n in support_data[2])}",
f" required: v{'.'.join(str(n) for n in min_version)}",
UserWarning,
)

Expand Down

0 comments on commit d69a067

Please sign in to comment.