Skip to content

Commit

Permalink
Assign clip.preview and clip.show in __init__.py to prevent confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
tburrows13 committed Jan 13, 2021
1 parent 5132dd8 commit 1048ee8
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
31 changes: 28 additions & 3 deletions moviepy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,21 @@
from moviepy.video.io.VideoFileClip import VideoFileClip
from moviepy.video.io.ImageSequenceClip import ImageSequenceClip
from moviepy.video.io.downloader import download_webfile
from moviepy.video.VideoClip import VideoClip, ImageClip, ColorClip, TextClip, BitmapClip
from moviepy.video.VideoClip import (
VideoClip,
ImageClip,
ColorClip,
TextClip,
BitmapClip,
)
from moviepy.video.compositing.CompositeVideoClip import CompositeVideoClip, clips_array
from moviepy.video.compositing.concatenate import concatenate_videoclips

from moviepy.audio.AudioClip import AudioClip, CompositeAudioClip, concatenate_audioclips
from moviepy.audio.AudioClip import (
AudioClip,
CompositeAudioClip,
concatenate_audioclips,
)
from moviepy.audio.io.AudioFileClip import AudioFileClip

# FX
Expand Down Expand Up @@ -52,6 +62,21 @@
for name, function in audio_fxs:
setattr(AudioClip, name, function)


def preview(self, *args, **kwargs):
"""NOT AVAILABLE: clip.preview requires importing from moviepy.editor"""
raise ImportError("clip.preview requires importing from moviepy.editor")


def show(self, *args, **kwargs):
"""NOT AVAILABLE: clip.show requires importing from moviepy.editor"""
raise ImportError("clip.show requires importing from moviepy.editor")


VideoClip.preview = preview
VideoClip.show = show
AudioClip.preview = preview

# Cleanup namespace
del audio_fxs, video_fxs, name, function
del audio_fxs, video_fxs, name, function, preview, show
del inspect
6 changes: 3 additions & 3 deletions moviepy/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def sliders(*args, **kwargs):
except ImportError:

def preview(self, *args, **kwargs):
"""NOT AVAILABLE : clip.preview requires Pygame installed."""
"""NOT AVAILABLE: clip.preview requires Pygame installed"""
raise ImportError("clip.preview requires Pygame installed")

def show(self, *args, **kwargs):
"""NOT AVAILABLE : clip.show requires Pygame installed."""
"""NOT AVAILABLE: clip.show requires Pygame installed"""
raise ImportError("clip.show requires Pygame installed")


Expand All @@ -57,7 +57,7 @@ def show(self, *args, **kwargs):
except ImportError:

def preview(self, *args, **kwargs):
""" NOT AVAILABLE : clip.preview requires Pygame installed."""
""" NOT AVAILABLE: clip.preview requires Pygame installed"""
raise ImportError("clip.preview requires Pygame installed")


Expand Down

0 comments on commit 1048ee8

Please sign in to comment.