forked from openlp/openlp
trunk
This commit is contained in:
commit
e0c8709ad1
@ -59,7 +59,6 @@ class Renderer(OpenLPMixin, RegistryMixin, RegistryProperties):
|
||||
"""
|
||||
super(Renderer, self).__init__(None)
|
||||
# Need live behaviour if this is also working as a pseudo MainDisplay.
|
||||
self.is_live = True
|
||||
self.screens = ScreenList()
|
||||
self.theme_level = ThemeLevel.Global
|
||||
self.global_theme_name = ''
|
||||
|
@ -66,11 +66,8 @@ class Display(QtGui.QGraphicsView):
|
||||
if hasattr(parent, 'is_live') and parent.is_live:
|
||||
self.is_live = True
|
||||
if self.is_live:
|
||||
super(Display, self).__init__()
|
||||
# Overwrite the parent() method.
|
||||
self.parent = lambda: parent
|
||||
else:
|
||||
super(Display, self).__init__(parent)
|
||||
super(Display, self).__init__()
|
||||
self.controller = parent
|
||||
self.screen = {}
|
||||
# FIXME: On Mac OS X (tested on 10.7) the display screen is corrupt with
|
||||
|
524
openlp/core/ui/media/vendor/vlc.py
vendored
524
openlp/core/ui/media/vendor/vlc.py
vendored
@ -48,7 +48,7 @@ import sys
|
||||
from inspect import getargspec
|
||||
|
||||
__version__ = "N/A"
|
||||
build_date = "Tue Jul 2 10:35:53 2013"
|
||||
build_date = "Wed Jun 25 13:46:01 2014"
|
||||
|
||||
if sys.version_info[0] > 2:
|
||||
str = str
|
||||
@ -110,7 +110,11 @@ def find_lib():
|
||||
p = find_library('libvlc.dll')
|
||||
if p is None:
|
||||
try: # some registry settings
|
||||
import _winreg as w # leaner than win32api, win32con
|
||||
# leaner than win32api, win32con
|
||||
if PYTHON3:
|
||||
import winreg as w
|
||||
else:
|
||||
import _winreg as w
|
||||
for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER:
|
||||
try:
|
||||
r = w.OpenKey(r, 'Software\\VideoLAN\\VLC')
|
||||
@ -365,6 +369,7 @@ class EventType(_Enum):
|
||||
3: 'MediaParsedChanged',
|
||||
4: 'MediaFreed',
|
||||
5: 'MediaStateChanged',
|
||||
6: 'MediaSubItemTreeAdded',
|
||||
0x100: 'MediaPlayerMediaChanged',
|
||||
257: 'MediaPlayerNothingSpecial',
|
||||
258: 'MediaPlayerOpening',
|
||||
@ -384,6 +389,7 @@ class EventType(_Enum):
|
||||
272: 'MediaPlayerSnapshotTaken',
|
||||
273: 'MediaPlayerLengthChanged',
|
||||
274: 'MediaPlayerVout',
|
||||
275: 'MediaPlayerScrambledChanged',
|
||||
0x200: 'MediaListItemAdded',
|
||||
513: 'MediaListWillAddItem',
|
||||
514: 'MediaListItemDeleted',
|
||||
@ -439,6 +445,7 @@ EventType.MediaPlayerPausableChanged = EventType(270)
|
||||
EventType.MediaPlayerPaused = EventType(261)
|
||||
EventType.MediaPlayerPlaying = EventType(260)
|
||||
EventType.MediaPlayerPositionChanged = EventType(268)
|
||||
EventType.MediaPlayerScrambledChanged = EventType(275)
|
||||
EventType.MediaPlayerSeekableChanged = EventType(269)
|
||||
EventType.MediaPlayerSnapshotTaken = EventType(272)
|
||||
EventType.MediaPlayerStopped = EventType(262)
|
||||
@ -447,6 +454,7 @@ EventType.MediaPlayerTitleChanged = EventType(271)
|
||||
EventType.MediaPlayerVout = EventType(274)
|
||||
EventType.MediaStateChanged = EventType(5)
|
||||
EventType.MediaSubItemAdded = EventType(1)
|
||||
EventType.MediaSubItemTreeAdded = EventType(6)
|
||||
EventType.VlmMediaAdded = EventType(0x600)
|
||||
EventType.VlmMediaChanged = EventType(1538)
|
||||
EventType.VlmMediaInstanceStarted = EventType(1539)
|
||||
@ -480,23 +488,35 @@ class Meta(_Enum):
|
||||
14: 'EncodedBy',
|
||||
15: 'ArtworkURL',
|
||||
16: 'TrackID',
|
||||
17: 'TrackTotal',
|
||||
18: 'Director',
|
||||
19: 'Season',
|
||||
20: 'Episode',
|
||||
21: 'ShowName',
|
||||
22: 'Actors',
|
||||
}
|
||||
Meta.Actors = Meta(22)
|
||||
Meta.Album = Meta(4)
|
||||
Meta.Artist = Meta(1)
|
||||
Meta.ArtworkURL = Meta(15)
|
||||
Meta.Copyright = Meta(3)
|
||||
Meta.Date = Meta(8)
|
||||
Meta.Description = Meta(6)
|
||||
Meta.Director = Meta(18)
|
||||
Meta.EncodedBy = Meta(14)
|
||||
Meta.Episode = Meta(20)
|
||||
Meta.Genre = Meta(2)
|
||||
Meta.Language = Meta(11)
|
||||
Meta.NowPlaying = Meta(12)
|
||||
Meta.Publisher = Meta(13)
|
||||
Meta.Rating = Meta(7)
|
||||
Meta.Season = Meta(19)
|
||||
Meta.Setting = Meta(9)
|
||||
Meta.ShowName = Meta(21)
|
||||
Meta.Title = Meta(0)
|
||||
Meta.TrackID = Meta(16)
|
||||
Meta.TrackNumber = Meta(5)
|
||||
Meta.TrackTotal = Meta(17)
|
||||
Meta.URL = Meta(10)
|
||||
|
||||
class State(_Enum):
|
||||
@ -594,6 +614,32 @@ NavigateMode.left = NavigateMode(3)
|
||||
NavigateMode.right = NavigateMode(4)
|
||||
NavigateMode.up = NavigateMode(1)
|
||||
|
||||
class Position(_Enum):
|
||||
'''Enumeration of values used to set position (e.g. of video title).
|
||||
'''
|
||||
_enum_names_ = {
|
||||
-1: 'disable',
|
||||
0: 'center',
|
||||
1: 'left',
|
||||
2: 'right',
|
||||
3: 'top',
|
||||
4: 'left',
|
||||
5: 'right',
|
||||
6: 'bottom',
|
||||
7: 'left',
|
||||
8: 'right',
|
||||
}
|
||||
Position.bottom = Position(6)
|
||||
Position.center = Position(0)
|
||||
Position.disable = Position(-1)
|
||||
Position.left = Position(1)
|
||||
Position.left = Position(4)
|
||||
Position.left = Position(7)
|
||||
Position.right = Position(2)
|
||||
Position.right = Position(5)
|
||||
Position.right = Position(8)
|
||||
Position.top = Position(3)
|
||||
|
||||
class VideoLogoOption(_Enum):
|
||||
'''Option values for libvlc_video_{get,set}_logo_{int,string}.
|
||||
'''
|
||||
@ -685,7 +731,7 @@ class LogCb(ctypes.c_void_p):
|
||||
"""Callback prototype for LibVLC log message handler.
|
||||
\param data data pointer as given to L{libvlc_log_set}()
|
||||
\param level message level (@ref enum libvlc_log_level)
|
||||
\param ctx message context (meta-informations about the message)
|
||||
\param ctx message context (meta-information about the message)
|
||||
\param fmt printf() format string (as defined by ISO C11)
|
||||
\param args variable argument list for the format
|
||||
\note Log message handlers <b>must</b> be thread-safe.
|
||||
@ -823,18 +869,18 @@ class CallbackDecorators(object):
|
||||
Callback = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
Callback.__doc__ = '''Callback function notification
|
||||
\param p_event the event triggering the callback
|
||||
'''
|
||||
'''
|
||||
LogCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int, Log_ptr, ctypes.c_char_p, ctypes.c_void_p)
|
||||
LogCb.__doc__ = '''Callback prototype for LibVLC log message handler.
|
||||
\param data data pointer as given to L{libvlc_log_set}()
|
||||
\param level message level (@ref enum libvlc_log_level)
|
||||
\param ctx message context (meta-informations about the message)
|
||||
\param ctx message context (meta-information about the message)
|
||||
\param fmt printf() format string (as defined by ISO C11)
|
||||
\param args variable argument list for the format
|
||||
\note Log message handlers <b>must</b> be thread-safe.
|
||||
\warning The message context pointer, the format string parameters and the
|
||||
variable arguments are only valid until the callback returns.
|
||||
'''
|
||||
'''
|
||||
VideoLockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p))
|
||||
VideoLockCb.__doc__ = '''Callback prototype to allocate and lock a picture buffer.
|
||||
Whenever a new video frame needs to be decoded, the lock callback is
|
||||
@ -846,7 +892,7 @@ planes must be aligned on 32-bytes boundaries.
|
||||
of void pointers, this callback must initialize the array) [OUT]
|
||||
\return a private pointer for the display and unlock callbacks to identify
|
||||
the picture buffers
|
||||
'''
|
||||
'''
|
||||
VideoUnlockCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ListPOINTER(ctypes.c_void_p))
|
||||
VideoUnlockCb.__doc__ = '''Callback prototype to unlock a picture buffer.
|
||||
When the video frame decoding is complete, the unlock callback is invoked.
|
||||
@ -859,7 +905,7 @@ but before the picture is displayed.
|
||||
callback [IN]
|
||||
\param planes pixel planes as defined by the @ref libvlc_video_lock_cb
|
||||
callback (this parameter is only for convenience) [IN]
|
||||
'''
|
||||
'''
|
||||
VideoDisplayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p)
|
||||
VideoDisplayCb.__doc__ = '''Callback prototype to display a picture.
|
||||
When the video frame needs to be shown, as determined by the media playback
|
||||
@ -867,7 +913,7 @@ clock, the display callback is invoked.
|
||||
\param opaque private pointer as passed to L{libvlc_video_set_callbacks}() [IN]
|
||||
\param picture private pointer returned from the @ref libvlc_video_lock_cb
|
||||
callback [IN]
|
||||
'''
|
||||
'''
|
||||
VideoFormatCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_uint), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
|
||||
VideoFormatCb.__doc__ = '''Callback prototype to configure picture buffers format.
|
||||
This callback gets the format of the video as output by the video decoder
|
||||
@ -891,47 +937,47 @@ the pixel height.
|
||||
Furthermore, we recommend that pitches and lines be multiple of 32
|
||||
to not break assumption that might be made by various optimizations
|
||||
in the video decoders, video filters and/or video converters.
|
||||
'''
|
||||
'''
|
||||
VideoCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
|
||||
VideoCleanupCb.__doc__ = '''Callback prototype to configure picture buffers format.
|
||||
\param opaque private pointer as passed to L{libvlc_video_set_callbacks}()
|
||||
(and possibly modified by @ref libvlc_video_format_cb) [IN]
|
||||
'''
|
||||
'''
|
||||
AudioPlayCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_uint, ctypes.c_int64)
|
||||
AudioPlayCb.__doc__ = '''Callback prototype for audio playback.
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
\param samples pointer to the first audio sample to play back [IN]
|
||||
\param count number of audio samples to play back
|
||||
\param pts expected play time stamp (see libvlc_delay())
|
||||
'''
|
||||
'''
|
||||
AudioPauseCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
|
||||
AudioPauseCb.__doc__ = '''Callback prototype for audio pause.
|
||||
\note The pause callback is never called if the audio is already paused.
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
\param pts time stamp of the pause request (should be elapsed already)
|
||||
'''
|
||||
'''
|
||||
AudioResumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
|
||||
AudioResumeCb.__doc__ = '''Callback prototype for audio resumption (i.e. restart from pause).
|
||||
\note The resume callback is never called if the audio is not paused.
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
\param pts time stamp of the resumption request (should be elapsed already)
|
||||
'''
|
||||
'''
|
||||
AudioFlushCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int64)
|
||||
AudioFlushCb.__doc__ = '''Callback prototype for audio buffer flush
|
||||
(i.e. discard all pending buffers and stop playback as soon as possible).
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
'''
|
||||
'''
|
||||
AudioDrainCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
|
||||
AudioDrainCb.__doc__ = '''Callback prototype for audio buffer drain
|
||||
(i.e. wait for pending buffers to be played).
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
'''
|
||||
'''
|
||||
AudioSetVolumeCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p, ctypes.c_float, ctypes.c_bool)
|
||||
AudioSetVolumeCb.__doc__ = '''Callback prototype for audio volume change.
|
||||
\param data data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
\param volume software volume (1. = nominal, 0. = mute)
|
||||
\param mute muted flag
|
||||
'''
|
||||
'''
|
||||
AudioSetupCb = ctypes.CFUNCTYPE(ctypes.POINTER(ctypes.c_int), ListPOINTER(ctypes.c_void_p), ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint), ctypes.POINTER(ctypes.c_uint))
|
||||
AudioSetupCb.__doc__ = '''Callback prototype to setup the audio playback.
|
||||
This is called when the media player needs to create a new audio output.
|
||||
@ -941,12 +987,12 @@ This is called when the media player needs to create a new audio output.
|
||||
\param rate sample rate [IN/OUT]
|
||||
\param channels channels count [IN/OUT]
|
||||
\return 0 on success, anything else to skip audio playback
|
||||
'''
|
||||
'''
|
||||
AudioCleanupCb = ctypes.CFUNCTYPE(ctypes.c_void_p, ctypes.c_void_p)
|
||||
AudioCleanupCb.__doc__ = '''Callback prototype for audio playback cleanup.
|
||||
This is called when the media player no longer needs an audio output.
|
||||
\param opaque data pointer as passed to L{libvlc_audio_set_callbacks}() [IN]
|
||||
'''
|
||||
'''
|
||||
cb = CallbackDecorators
|
||||
# End of generated enum types #
|
||||
|
||||
@ -1210,7 +1256,7 @@ class EventManager(_Ctype):
|
||||
|
||||
@note: Only a single notification can be registered
|
||||
for each event type in an EventManager instance.
|
||||
|
||||
|
||||
'''
|
||||
|
||||
_callback_handler = None
|
||||
@ -1287,7 +1333,7 @@ class Instance(_Ctype):
|
||||
- a string
|
||||
- a list of strings as first parameters
|
||||
- the parameters given as the constructor parameters (must be strings)
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def __new__(cls, *args):
|
||||
@ -1432,6 +1478,16 @@ class Instance(_Ctype):
|
||||
'''
|
||||
return libvlc_set_user_agent(self, str_to_bytes(name), str_to_bytes(http))
|
||||
|
||||
def set_app_id(self, id, version, icon):
|
||||
'''Sets some meta-information about the application.
|
||||
See also L{set_user_agent}().
|
||||
@param id: Java-style application identifier, e.g. "com.acme.foobar".
|
||||
@param version: application version numbers, e.g. "1.2.3".
|
||||
@param icon: application icon name, e.g. "foobar".
|
||||
@version: LibVLC 2.1.0 or later.
|
||||
'''
|
||||
return libvlc_set_app_id(self, str_to_bytes(id), str_to_bytes(version), str_to_bytes(icon))
|
||||
|
||||
def log_unset(self):
|
||||
'''Unsets the logging callback for a LibVLC instance. This is rarely needed:
|
||||
the callback is implicitly unset when the instance is destroyed.
|
||||
@ -1521,13 +1577,13 @@ class Instance(_Ctype):
|
||||
return libvlc_media_library_new(self)
|
||||
|
||||
def audio_output_list_get(self):
|
||||
'''Gets the list of available audio outputs.
|
||||
'''Gets the list of available audio output modules.
|
||||
@return: list of available audio outputs. It must be freed it with In case of error, NULL is returned.
|
||||
'''
|
||||
return libvlc_audio_output_list_get(self)
|
||||
|
||||
def audio_output_device_list_get(self, aout):
|
||||
'''Gets a list of audio output devices for a given audio output.
|
||||
'''Gets a list of audio output devices for a given audio output module,
|
||||
See L{audio_output_device_set}().
|
||||
@note: Not all audio outputs support this. In particular, an empty (NULL)
|
||||
list of devices does B{not} imply that the specified audio output does
|
||||
@ -1753,11 +1809,11 @@ class Instance(_Ctype):
|
||||
|
||||
class Media(_Ctype):
|
||||
'''Create a new Media instance.
|
||||
|
||||
|
||||
Usage: Media(MRL, *options)
|
||||
|
||||
See vlc.Instance.media_new documentation for details.
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def __new__(cls, *args):
|
||||
@ -1790,6 +1846,19 @@ class Media(_Ctype):
|
||||
for o in options:
|
||||
self.add_option(o)
|
||||
|
||||
def tracks_get(self):
|
||||
"""Get media descriptor's elementary streams description
|
||||
Note, you need to call L{parse}() or play the media at least once
|
||||
before calling this function.
|
||||
Not doing this will result in an empty array.
|
||||
The result must be freed with L{tracks_release}.
|
||||
@version: LibVLC 2.1.0 and later.
|
||||
"""
|
||||
mediaTrack_pp = ctypes.POINTER(MediaTrack)()
|
||||
n = libvlc_media_tracks_get(self, byref(mediaTrack_pp))
|
||||
info = cast(ctypes.mediaTrack_pp, ctypes.POINTER(ctypes.POINTER(MediaTrack) * n))
|
||||
return info
|
||||
|
||||
|
||||
def add_option(self, psz_options):
|
||||
'''Add an option to the media.
|
||||
@ -1962,17 +2031,6 @@ class Media(_Ctype):
|
||||
'''
|
||||
return libvlc_media_get_user_data(self)
|
||||
|
||||
def tracks_get(self, tracks):
|
||||
'''Get media descriptor's elementary streams description
|
||||
Note, you need to call L{parse}() or play the media at least once
|
||||
before calling this function.
|
||||
Not doing this will result in an empty array.
|
||||
@param tracks: address to store an allocated array of Elementary Streams descriptions (must be freed with L{tracks_release}.
|
||||
@return: the number of Elementary Streams (zero on error).
|
||||
@version: LibVLC 2.1.0 and later.
|
||||
'''
|
||||
return libvlc_media_tracks_get(self, tracks)
|
||||
|
||||
def player_new_from_media(self):
|
||||
'''Create a Media Player object from a Media.
|
||||
@return: a new media player object, or NULL on error.
|
||||
@ -2053,11 +2111,11 @@ class MediaLibrary(_Ctype):
|
||||
|
||||
class MediaList(_Ctype):
|
||||
'''Create a new MediaList instance.
|
||||
|
||||
|
||||
Usage: MediaList(list_of_MRLs)
|
||||
|
||||
See vlc.Instance.media_list_new documentation for details.
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def __new__(cls, *args):
|
||||
@ -2073,10 +2131,10 @@ class MediaList(_Ctype):
|
||||
|
||||
def get_instance(self):
|
||||
return getattr(self, '_instance', None)
|
||||
|
||||
|
||||
def add_media(self, mrl):
|
||||
"""Add media instance to media list.
|
||||
|
||||
|
||||
The L{lock} should be held upon entering this function.
|
||||
@param mrl: a media instance or a MRL.
|
||||
@return: 0 on success, -1 if the media list is read-only.
|
||||
@ -2193,7 +2251,7 @@ class MediaListPlayer(_Ctype):
|
||||
It may take as parameter either:
|
||||
- a vlc.Instance
|
||||
- nothing
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def __new__(cls, arg=None):
|
||||
@ -2319,13 +2377,13 @@ class MediaPlayer(_Ctype):
|
||||
It may take as parameter either:
|
||||
- a string (media URI), options... In this case, a vlc.Instance will be created.
|
||||
- a vlc.Instance, a string (media URI), options...
|
||||
|
||||
|
||||
'''
|
||||
|
||||
def __new__(cls, *args):
|
||||
if len(args) == 1 and isinstance(args[0], _Ints):
|
||||
return _Constructor(cls, args[0])
|
||||
|
||||
|
||||
if args and isinstance(args[0], Instance):
|
||||
instance = args[0]
|
||||
args = args[1:]
|
||||
@ -2397,13 +2455,13 @@ class MediaPlayer(_Ctype):
|
||||
Specify where the media player should render its video
|
||||
output. If LibVLC was built without Win32/Win64 API output
|
||||
support, then this has no effects.
|
||||
|
||||
|
||||
@param drawable: windows handle of the drawable.
|
||||
"""
|
||||
if not isinstance(drawable, ctypes.c_void_p):
|
||||
drawable = ctypes.c_void_p(int(drawable))
|
||||
libvlc_media_player_set_hwnd(self, drawable)
|
||||
|
||||
|
||||
def video_get_width(self, num=0):
|
||||
"""Get the width of a video in pixels.
|
||||
|
||||
@ -2556,12 +2614,12 @@ class MediaPlayer(_Ctype):
|
||||
If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then
|
||||
the following code should work:
|
||||
@begincode
|
||||
|
||||
|
||||
NSView *video = [[NSView alloc] init];
|
||||
QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
|
||||
L{set_nsobject}(mp, video);
|
||||
[video release];
|
||||
|
||||
|
||||
@endcode
|
||||
You can find a live example in VLCVideoView in VLCKit.framework.
|
||||
@param drawable: the drawable that is either an NSView or an object following the VLCOpenGLVideoViewEmbedding protocol.
|
||||
@ -2796,6 +2854,13 @@ class MediaPlayer(_Ctype):
|
||||
'''
|
||||
return libvlc_media_player_can_pause(self)
|
||||
|
||||
def program_scrambled(self):
|
||||
'''Check if the current program is scrambled.
|
||||
@return: true if the current program is scrambled \libvlc_return_bool.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
return libvlc_media_player_program_scrambled(self)
|
||||
|
||||
def next_frame(self):
|
||||
'''Display the next frame (if supported).
|
||||
'''
|
||||
@ -2808,6 +2873,14 @@ class MediaPlayer(_Ctype):
|
||||
'''
|
||||
return libvlc_media_player_navigate(self, navigate)
|
||||
|
||||
def set_video_title_display(self, position, timeout):
|
||||
'''Set if, and how, the video title will be shown when media is played.
|
||||
@param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed.
|
||||
@param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable).
|
||||
@version: libVLC 2.1.0 or later.
|
||||
'''
|
||||
return libvlc_media_player_set_video_title_display(self, position, timeout)
|
||||
|
||||
def toggle_fullscreen(self):
|
||||
'''Toggle fullscreen status on non-embedded video outputs.
|
||||
@warning: The same limitations applies to this function
|
||||
@ -3083,7 +3156,7 @@ class MediaPlayer(_Ctype):
|
||||
return libvlc_video_set_adjust_float(self, option, value)
|
||||
|
||||
def audio_output_set(self, psz_name):
|
||||
'''Sets the audio output.
|
||||
'''Selects an audio output module.
|
||||
@note: Any change will take be effect only after playback is stopped and
|
||||
restarted. Audio output cannot be changed while playing.
|
||||
@param psz_name: name of audio output, use psz_name of See L{AudioOutput}.
|
||||
@ -3091,21 +3164,46 @@ class MediaPlayer(_Ctype):
|
||||
'''
|
||||
return libvlc_audio_output_set(self, str_to_bytes(psz_name))
|
||||
|
||||
def audio_output_device_set(self, psz_audio_output, psz_device_id):
|
||||
'''Configures an explicit audio output device for a given audio output plugin.
|
||||
A list of possible devices can be obtained with
|
||||
def audio_output_device_enum(self):
|
||||
'''Gets a list of potential audio output devices,
|
||||
See L{audio_output_device_set}().
|
||||
@note: Not all audio outputs support enumerating devices.
|
||||
The audio output may be functional even if the list is empty (NULL).
|
||||
@note: The list may not be exhaustive.
|
||||
@warning: Some audio output devices in the list might not actually work in
|
||||
some circumstances. By default, it is recommended to not specify any
|
||||
explicit audio device.
|
||||
@return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{audio_output_device_list_release}().
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
return libvlc_audio_output_device_enum(self)
|
||||
|
||||
def audio_output_device_set(self, module, device_id):
|
||||
'''Configures an explicit audio output device.
|
||||
If the module paramater is NULL, audio output will be moved to the device
|
||||
specified by the device identifier string immediately. This is the
|
||||
recommended usage.
|
||||
A list of adequate potential device strings can be obtained with
|
||||
L{audio_output_device_enum}().
|
||||
However passing NULL is supported in LibVLC version 2.2.0 and later only;
|
||||
in earlier versions, this function would have no effects when the module
|
||||
parameter was NULL.
|
||||
If the module parameter is not NULL, the device parameter of the
|
||||
corresponding audio output, if it exists, will be set to the specified
|
||||
string. Note that some audio output modules do not have such a parameter
|
||||
(notably MMDevice and PulseAudio).
|
||||
A list of adequate potential device strings can be obtained with
|
||||
L{audio_output_device_list_get}().
|
||||
@note: This function does not select the specified audio output plugin.
|
||||
L{audio_output_set}() is used for that purpose.
|
||||
@warning: The syntax for the device parameter depends on the audio output.
|
||||
This is not portable. Only use this function if you know what you are doing.
|
||||
Some audio outputs do not support this function (e.g. PulseAudio, WASAPI).
|
||||
Some audio outputs require further parameters (e.g. ALSA: channels map).
|
||||
@param psz_audio_output: - name of audio output, See L{AudioOutput}.
|
||||
@param psz_device_id: device.
|
||||
@return: Nothing. Errors are ignored.
|
||||
Some audio output modules require further parameters (e.g. a channels map
|
||||
in the case of ALSA).
|
||||
@param module: If NULL, current audio output module. if non-NULL, name of audio output module.
|
||||
@param device_id: device identifier string.
|
||||
@return: Nothing. Errors are ignored (this is a design bug).
|
||||
'''
|
||||
return libvlc_audio_output_device_set(self, str_to_bytes(psz_audio_output), str_to_bytes(psz_device_id))
|
||||
return libvlc_audio_output_device_set(self, str_to_bytes(module), str_to_bytes(device_id))
|
||||
|
||||
def audio_toggle_mute(self):
|
||||
'''Toggle mute status.
|
||||
@ -3184,6 +3282,28 @@ class MediaPlayer(_Ctype):
|
||||
'''
|
||||
return libvlc_audio_set_delay(self, i_delay)
|
||||
|
||||
def set_equalizer(self, p_equalizer):
|
||||
'''Apply new equalizer settings to a media player.
|
||||
The equalizer is first created by invoking L{audio_equalizer_new}() or
|
||||
L{audio_equalizer_new_from_preset}().
|
||||
It is possible to apply new equalizer settings to a media player whether the media
|
||||
player is currently playing media or not.
|
||||
Invoking this method will immediately apply the new equalizer settings to the audio
|
||||
output of the currently playing media if there is any.
|
||||
If there is no currently playing media, the new equalizer settings will be applied
|
||||
later if and when new media is played.
|
||||
Equalizer settings will automatically be applied to subsequently played media.
|
||||
To disable the equalizer for a media player invoke this method passing NULL for the
|
||||
p_equalizer parameter.
|
||||
The media player does not keep a reference to the supplied equalizer so it is safe
|
||||
for an application to release the equalizer reference any time after this method
|
||||
returns.
|
||||
@param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player.
|
||||
@return: zero on success, -1 on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
return libvlc_media_player_set_equalizer(self, p_equalizer)
|
||||
|
||||
|
||||
# LibVLC __version__ functions #
|
||||
|
||||
@ -3279,6 +3399,20 @@ def libvlc_set_user_agent(p_instance, name, http):
|
||||
None, Instance, ctypes.c_char_p, ctypes.c_char_p)
|
||||
return f(p_instance, name, http)
|
||||
|
||||
def libvlc_set_app_id(p_instance, id, version, icon):
|
||||
'''Sets some meta-information about the application.
|
||||
See also L{libvlc_set_user_agent}().
|
||||
@param p_instance: LibVLC instance.
|
||||
@param id: Java-style application identifier, e.g. "com.acme.foobar".
|
||||
@param version: application version numbers, e.g. "1.2.3".
|
||||
@param icon: application icon name, e.g. "foobar".
|
||||
@version: LibVLC 2.1.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_set_app_id', None) or \
|
||||
_Cfunction('libvlc_set_app_id', ((1,), (1,), (1,), (1,),), None,
|
||||
None, Instance, ctypes.c_char_p, ctypes.c_char_p, ctypes.c_char_p)
|
||||
return f(p_instance, id, version, icon)
|
||||
|
||||
def libvlc_get_version():
|
||||
'''Retrieve libvlc version.
|
||||
Example: "1.1.0-git The Luggage".
|
||||
@ -3355,7 +3489,7 @@ def libvlc_event_type_name(event_type):
|
||||
return f(event_type)
|
||||
|
||||
def libvlc_log_get_context(ctx):
|
||||
'''Gets debugging informations about a log message: the name of the VLC module
|
||||
'''Gets debugging information about a log message: the name of the VLC module
|
||||
emitting the message and the message location within the source code.
|
||||
The returned module name and file name will be NULL if unknown.
|
||||
The returned line number will similarly be zero if unknown.
|
||||
@ -3369,9 +3503,9 @@ def libvlc_log_get_context(ctx):
|
||||
return f(ctx)
|
||||
|
||||
def libvlc_log_get_object(ctx, id):
|
||||
'''Gets VLC object informations about a log message: the type name of the VLC
|
||||
'''Gets VLC object information about a log message: the type name of the VLC
|
||||
object emitting the message, the object header if any and a temporaly-unique
|
||||
object identifier. These informations are mainly meant for B{manual}
|
||||
object identifier. This information is mainly meant for B{manual}
|
||||
troubleshooting.
|
||||
The returned type name may be "generic" if unknown, but it cannot be NULL.
|
||||
The returned header will be NULL if unset; in current versions, the header
|
||||
@ -4430,12 +4564,12 @@ def libvlc_media_player_set_nsobject(p_mi, drawable):
|
||||
If you want to use it along with Qt4 see the QMacCocoaViewContainer. Then
|
||||
the following code should work:
|
||||
@begincode
|
||||
|
||||
|
||||
NSView *video = [[NSView alloc] init];
|
||||
QMacCocoaViewContainer *container = new QMacCocoaViewContainer(video, parent);
|
||||
L{libvlc_media_player_set_nsobject}(mp, video);
|
||||
[video release];
|
||||
|
||||
|
||||
@endcode
|
||||
You can find a live example in VLCVideoView in VLCKit.framework.
|
||||
@param p_mi: the Media Player.
|
||||
@ -4814,6 +4948,17 @@ def libvlc_media_player_can_pause(p_mi):
|
||||
ctypes.c_int, MediaPlayer)
|
||||
return f(p_mi)
|
||||
|
||||
def libvlc_media_player_program_scrambled(p_mi):
|
||||
'''Check if the current program is scrambled.
|
||||
@param p_mi: the media player.
|
||||
@return: true if the current program is scrambled \libvlc_return_bool.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_media_player_program_scrambled', None) or \
|
||||
_Cfunction('libvlc_media_player_program_scrambled', ((1,),), None,
|
||||
ctypes.c_int, MediaPlayer)
|
||||
return f(p_mi)
|
||||
|
||||
def libvlc_media_player_next_frame(p_mi):
|
||||
'''Display the next frame (if supported).
|
||||
@param p_mi: the media player.
|
||||
@ -4834,6 +4979,18 @@ def libvlc_media_player_navigate(p_mi, navigate):
|
||||
None, MediaPlayer, ctypes.c_uint)
|
||||
return f(p_mi, navigate)
|
||||
|
||||
def libvlc_media_player_set_video_title_display(p_mi, position, timeout):
|
||||
'''Set if, and how, the video title will be shown when media is played.
|
||||
@param p_mi: the media player.
|
||||
@param position: position at which to display the title, or libvlc_position_disable to prevent the title from being displayed.
|
||||
@param timeout: title display timeout in milliseconds (ignored if libvlc_position_disable).
|
||||
@version: libVLC 2.1.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_media_player_set_video_title_display', None) or \
|
||||
_Cfunction('libvlc_media_player_set_video_title_display', ((1,), (1,), (1,),), None,
|
||||
None, MediaPlayer, Position, ctypes.c_int)
|
||||
return f(p_mi, position, timeout)
|
||||
|
||||
def libvlc_track_description_list_release(p_track_description):
|
||||
'''Release (free) L{TrackDescription}.
|
||||
@param p_track_description: the structure to release.
|
||||
@ -5335,7 +5492,7 @@ def libvlc_video_set_adjust_float(p_mi, option, value):
|
||||
return f(p_mi, option, value)
|
||||
|
||||
def libvlc_audio_output_list_get(p_instance):
|
||||
'''Gets the list of available audio outputs.
|
||||
'''Gets the list of available audio output modules.
|
||||
@param p_instance: libvlc instance.
|
||||
@return: list of available audio outputs. It must be freed it with In case of error, NULL is returned.
|
||||
'''
|
||||
@ -5345,7 +5502,7 @@ def libvlc_audio_output_list_get(p_instance):
|
||||
return f(p_instance)
|
||||
|
||||
def libvlc_audio_output_list_release(p_list):
|
||||
'''Frees the list of available audio outputs.
|
||||
'''Frees the list of available audio output modules.
|
||||
@param p_list: list with audio outputs for release.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_output_list_release', None) or \
|
||||
@ -5354,7 +5511,7 @@ def libvlc_audio_output_list_release(p_list):
|
||||
return f(p_list)
|
||||
|
||||
def libvlc_audio_output_set(p_mi, psz_name):
|
||||
'''Sets the audio output.
|
||||
'''Selects an audio output module.
|
||||
@note: Any change will take be effect only after playback is stopped and
|
||||
restarted. Audio output cannot be changed while playing.
|
||||
@param p_mi: media player.
|
||||
@ -5366,8 +5523,26 @@ def libvlc_audio_output_set(p_mi, psz_name):
|
||||
ctypes.c_int, MediaPlayer, ctypes.c_char_p)
|
||||
return f(p_mi, psz_name)
|
||||
|
||||
def libvlc_audio_output_device_enum(mp):
|
||||
'''Gets a list of potential audio output devices,
|
||||
See L{libvlc_audio_output_device_set}().
|
||||
@note: Not all audio outputs support enumerating devices.
|
||||
The audio output may be functional even if the list is empty (NULL).
|
||||
@note: The list may not be exhaustive.
|
||||
@warning: Some audio output devices in the list might not actually work in
|
||||
some circumstances. By default, it is recommended to not specify any
|
||||
explicit audio device.
|
||||
@param mp: media player.
|
||||
@return: A NULL-terminated linked list of potential audio output devices. It must be freed it with L{libvlc_audio_output_device_list_release}().
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_output_device_enum', None) or \
|
||||
_Cfunction('libvlc_audio_output_device_enum', ((1,),), None,
|
||||
ctypes.POINTER(AudioOutputDevice), MediaPlayer)
|
||||
return f(mp)
|
||||
|
||||
def libvlc_audio_output_device_list_get(p_instance, aout):
|
||||
'''Gets a list of audio output devices for a given audio output.
|
||||
'''Gets a list of audio output devices for a given audio output module,
|
||||
See L{libvlc_audio_output_device_set}().
|
||||
@note: Not all audio outputs support this. In particular, an empty (NULL)
|
||||
list of devices does B{not} imply that the specified audio output does
|
||||
@ -5396,25 +5571,36 @@ def libvlc_audio_output_device_list_release(p_list):
|
||||
None, ctypes.POINTER(AudioOutputDevice))
|
||||
return f(p_list)
|
||||
|
||||
def libvlc_audio_output_device_set(p_mi, psz_audio_output, psz_device_id):
|
||||
'''Configures an explicit audio output device for a given audio output plugin.
|
||||
A list of possible devices can be obtained with
|
||||
def libvlc_audio_output_device_set(mp, module, device_id):
|
||||
'''Configures an explicit audio output device.
|
||||
If the module paramater is NULL, audio output will be moved to the device
|
||||
specified by the device identifier string immediately. This is the
|
||||
recommended usage.
|
||||
A list of adequate potential device strings can be obtained with
|
||||
L{libvlc_audio_output_device_enum}().
|
||||
However passing NULL is supported in LibVLC version 2.2.0 and later only;
|
||||
in earlier versions, this function would have no effects when the module
|
||||
parameter was NULL.
|
||||
If the module parameter is not NULL, the device parameter of the
|
||||
corresponding audio output, if it exists, will be set to the specified
|
||||
string. Note that some audio output modules do not have such a parameter
|
||||
(notably MMDevice and PulseAudio).
|
||||
A list of adequate potential device strings can be obtained with
|
||||
L{libvlc_audio_output_device_list_get}().
|
||||
@note: This function does not select the specified audio output plugin.
|
||||
L{libvlc_audio_output_set}() is used for that purpose.
|
||||
@warning: The syntax for the device parameter depends on the audio output.
|
||||
This is not portable. Only use this function if you know what you are doing.
|
||||
Some audio outputs do not support this function (e.g. PulseAudio, WASAPI).
|
||||
Some audio outputs require further parameters (e.g. ALSA: channels map).
|
||||
@param p_mi: media player.
|
||||
@param psz_audio_output: - name of audio output, See L{AudioOutput}.
|
||||
@param psz_device_id: device.
|
||||
@return: Nothing. Errors are ignored.
|
||||
Some audio output modules require further parameters (e.g. a channels map
|
||||
in the case of ALSA).
|
||||
@param mp: media player.
|
||||
@param module: If NULL, current audio output module. if non-NULL, name of audio output module.
|
||||
@param device_id: device identifier string.
|
||||
@return: Nothing. Errors are ignored (this is a design bug).
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_output_device_set', None) or \
|
||||
_Cfunction('libvlc_audio_output_device_set', ((1,), (1,), (1,),), None,
|
||||
None, MediaPlayer, ctypes.c_char_p, ctypes.c_char_p)
|
||||
return f(p_mi, psz_audio_output, psz_device_id)
|
||||
return f(mp, module, device_id)
|
||||
|
||||
def libvlc_audio_toggle_mute(p_mi):
|
||||
'''Toggle mute status.
|
||||
@ -5551,6 +5737,175 @@ def libvlc_audio_set_delay(p_mi, i_delay):
|
||||
ctypes.c_int, MediaPlayer, ctypes.c_int64)
|
||||
return f(p_mi, i_delay)
|
||||
|
||||
def libvlc_audio_equalizer_get_preset_count():
|
||||
'''Get the number of equalizer presets.
|
||||
@return: number of presets.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_count', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_preset_count', (), None,
|
||||
ctypes.c_uint)
|
||||
return f()
|
||||
|
||||
def libvlc_audio_equalizer_get_preset_name(u_index):
|
||||
'''Get the name of a particular equalizer preset.
|
||||
This name can be used, for example, to prepare a preset label or menu in a user
|
||||
interface.
|
||||
@param u_index: index of the preset, counting from zero.
|
||||
@return: preset name, or NULL if there is no such preset.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_preset_name', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_preset_name', ((1,),), None,
|
||||
ctypes.c_char_p, ctypes.c_uint)
|
||||
return f(u_index)
|
||||
|
||||
def libvlc_audio_equalizer_get_band_count():
|
||||
'''Get the number of distinct frequency bands for an equalizer.
|
||||
@return: number of frequency bands.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_band_count', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_band_count', (), None,
|
||||
ctypes.c_uint)
|
||||
return f()
|
||||
|
||||
def libvlc_audio_equalizer_get_band_frequency(u_index):
|
||||
'''Get a particular equalizer band frequency.
|
||||
This value can be used, for example, to create a label for an equalizer band control
|
||||
in a user interface.
|
||||
@param u_index: index of the band, counting from zero.
|
||||
@return: equalizer band frequency (Hz), or -1 if there is no such band.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_band_frequency', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_band_frequency', ((1,),), None,
|
||||
ctypes.c_float, ctypes.c_uint)
|
||||
return f(u_index)
|
||||
|
||||
def libvlc_audio_equalizer_new():
|
||||
'''Create a new default equalizer, with all frequency values zeroed.
|
||||
The new equalizer can subsequently be applied to a media player by invoking
|
||||
L{libvlc_media_player_set_equalizer}().
|
||||
The returned handle should be freed via L{libvlc_audio_equalizer_release}() when
|
||||
it is no longer needed.
|
||||
@return: opaque equalizer handle, or NULL on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_new', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_new', (), None,
|
||||
ctypes.c_void_p)
|
||||
return f()
|
||||
|
||||
def libvlc_audio_equalizer_new_from_preset(u_index):
|
||||
'''Create a new equalizer, with initial frequency values copied from an existing
|
||||
preset.
|
||||
The new equalizer can subsequently be applied to a media player by invoking
|
||||
L{libvlc_media_player_set_equalizer}().
|
||||
The returned handle should be freed via L{libvlc_audio_equalizer_release}() when
|
||||
it is no longer needed.
|
||||
@param u_index: index of the preset, counting from zero.
|
||||
@return: opaque equalizer handle, or NULL on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_new_from_preset', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_new_from_preset', ((1,),), None,
|
||||
ctypes.c_void_p, ctypes.c_uint)
|
||||
return f(u_index)
|
||||
|
||||
def libvlc_audio_equalizer_release(p_equalizer):
|
||||
'''Release a previously created equalizer instance.
|
||||
The equalizer was previously created by using L{libvlc_audio_equalizer_new}() or
|
||||
L{libvlc_audio_equalizer_new_from_preset}().
|
||||
It is safe to invoke this method with a NULL p_equalizer parameter for no effect.
|
||||
@param p_equalizer: opaque equalizer handle, or NULL.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_release', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_release', ((1,),), None,
|
||||
None, ctypes.c_void_p)
|
||||
return f(p_equalizer)
|
||||
|
||||
def libvlc_audio_equalizer_set_preamp(p_equalizer, f_preamp):
|
||||
'''Set a new pre-amplification value for an equalizer.
|
||||
The new equalizer settings are subsequently applied to a media player by invoking
|
||||
L{libvlc_media_player_set_equalizer}().
|
||||
The supplied amplification value will be clamped to the -20.0 to +20.0 range.
|
||||
@param p_equalizer: valid equalizer handle, must not be NULL.
|
||||
@param f_preamp: preamp value (-20.0 to 20.0 Hz).
|
||||
@return: zero on success, -1 on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_set_preamp', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_set_preamp', ((1,), (1,),), None,
|
||||
ctypes.c_int, ctypes.c_void_p, ctypes.c_float)
|
||||
return f(p_equalizer, f_preamp)
|
||||
|
||||
def libvlc_audio_equalizer_get_preamp(p_equalizer):
|
||||
'''Get the current pre-amplification value from an equalizer.
|
||||
@param p_equalizer: valid equalizer handle, must not be NULL.
|
||||
@return: preamp value (Hz).
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_preamp', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_preamp', ((1,),), None,
|
||||
ctypes.c_float, ctypes.c_void_p)
|
||||
return f(p_equalizer)
|
||||
|
||||
def libvlc_audio_equalizer_set_amp_at_index(p_equalizer, f_amp, u_band):
|
||||
'''Set a new amplification value for a particular equalizer frequency band.
|
||||
The new equalizer settings are subsequently applied to a media player by invoking
|
||||
L{libvlc_media_player_set_equalizer}().
|
||||
The supplied amplification value will be clamped to the -20.0 to +20.0 range.
|
||||
@param p_equalizer: valid equalizer handle, must not be NULL.
|
||||
@param f_amp: amplification value (-20.0 to 20.0 Hz).
|
||||
@param u_band: index, counting from zero, of the frequency band to set.
|
||||
@return: zero on success, -1 on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_set_amp_at_index', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_set_amp_at_index', ((1,), (1,), (1,),), None,
|
||||
ctypes.c_int, ctypes.c_void_p, ctypes.c_float, ctypes.c_uint)
|
||||
return f(p_equalizer, f_amp, u_band)
|
||||
|
||||
def libvlc_audio_equalizer_get_amp_at_index(p_equalizer, u_band):
|
||||
'''Get the amplification value for a particular equalizer frequency band.
|
||||
@param p_equalizer: valid equalizer handle, must not be NULL.
|
||||
@param u_band: index, counting from zero, of the frequency band to get.
|
||||
@return: amplification value (Hz); NaN if there is no such frequency band.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_audio_equalizer_get_amp_at_index', None) or \
|
||||
_Cfunction('libvlc_audio_equalizer_get_amp_at_index', ((1,), (1,),), None,
|
||||
ctypes.c_float, ctypes.c_void_p, ctypes.c_uint)
|
||||
return f(p_equalizer, u_band)
|
||||
|
||||
def libvlc_media_player_set_equalizer(p_mi, p_equalizer):
|
||||
'''Apply new equalizer settings to a media player.
|
||||
The equalizer is first created by invoking L{libvlc_audio_equalizer_new}() or
|
||||
L{libvlc_audio_equalizer_new_from_preset}().
|
||||
It is possible to apply new equalizer settings to a media player whether the media
|
||||
player is currently playing media or not.
|
||||
Invoking this method will immediately apply the new equalizer settings to the audio
|
||||
output of the currently playing media if there is any.
|
||||
If there is no currently playing media, the new equalizer settings will be applied
|
||||
later if and when new media is played.
|
||||
Equalizer settings will automatically be applied to subsequently played media.
|
||||
To disable the equalizer for a media player invoke this method passing NULL for the
|
||||
p_equalizer parameter.
|
||||
The media player does not keep a reference to the supplied equalizer so it is safe
|
||||
for an application to release the equalizer reference any time after this method
|
||||
returns.
|
||||
@param p_mi: opaque media player handle.
|
||||
@param p_equalizer: opaque equalizer handle, or NULL to disable the equalizer for this media player.
|
||||
@return: zero on success, -1 on error.
|
||||
@version: LibVLC 2.2.0 or later.
|
||||
'''
|
||||
f = _Cfunctions.get('libvlc_media_player_set_equalizer', None) or \
|
||||
_Cfunction('libvlc_media_player_set_equalizer', ((1,), (1,),), None,
|
||||
ctypes.c_int, MediaPlayer, ctypes.c_void_p)
|
||||
return f(p_mi, p_equalizer)
|
||||
|
||||
def libvlc_vlm_release(p_instance):
|
||||
'''Release the vlm instance related to the given L{Instance}.
|
||||
@param p_instance: the instance.
|
||||
@ -5863,7 +6218,18 @@ def libvlc_vlm_get_event_manager(p_instance):
|
||||
# libvlc_printerr
|
||||
# libvlc_set_exit_handler
|
||||
|
||||
# 17 function(s) not wrapped as methods:
|
||||
# 28 function(s) not wrapped as methods:
|
||||
# libvlc_audio_equalizer_get_amp_at_index
|
||||
# libvlc_audio_equalizer_get_band_count
|
||||
# libvlc_audio_equalizer_get_band_frequency
|
||||
# libvlc_audio_equalizer_get_preamp
|
||||
# libvlc_audio_equalizer_get_preset_count
|
||||
# libvlc_audio_equalizer_get_preset_name
|
||||
# libvlc_audio_equalizer_new
|
||||
# libvlc_audio_equalizer_new_from_preset
|
||||
# libvlc_audio_equalizer_release
|
||||
# libvlc_audio_equalizer_set_amp_at_index
|
||||
# libvlc_audio_equalizer_set_preamp
|
||||
# libvlc_audio_output_device_list_release
|
||||
# libvlc_audio_output_list_release
|
||||
# libvlc_clearerr
|
||||
|
@ -149,9 +149,9 @@ def get_application_version():
|
||||
# If they are equal, then this tree is tarball with the source for the release. We do not want the revision
|
||||
# number in the full version.
|
||||
if tree_revision == tag_revision:
|
||||
full_version = tag_version
|
||||
full_version = tag_version.decode('utf-8')
|
||||
else:
|
||||
full_version = '%s-bzr%s' % (tag_version, tree_revision)
|
||||
full_version = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8'))
|
||||
else:
|
||||
# We're not running the development version, let's use the file.
|
||||
filepath = AppLocation.get_directory(AppLocation.VersionDir)
|
||||
|
@ -225,7 +225,7 @@ class BGExtract(RegistryProperties):
|
||||
url_book_name = urllib.parse.quote(book_name.encode("utf-8"))
|
||||
url_params = 'search=%s+%s&version=%s' % (url_book_name, chapter, version)
|
||||
soup = get_soup_for_bible_ref(
|
||||
'http://www.biblegateway.com/passage/?%s' % url_params,
|
||||
'http://legacy.biblegateway.com/passage/?%s' % url_params,
|
||||
pre_parse_regex=r'<meta name.*?/>', pre_parse_substitute='')
|
||||
if not soup:
|
||||
return None
|
||||
@ -252,7 +252,7 @@ class BGExtract(RegistryProperties):
|
||||
"""
|
||||
log.debug('BGExtract.get_books_from_http("%s")', version)
|
||||
url_params = urllib.parse.urlencode({'action': 'getVersionInfo', 'vid': '%s' % version})
|
||||
reference_url = 'http://www.biblegateway.com/versions/?%s#books' % url_params
|
||||
reference_url = 'http://legacy.biblegateway.com/versions/?%s#books' % url_params
|
||||
page = get_web_page(reference_url)
|
||||
if not page:
|
||||
send_error_message('download')
|
||||
|
@ -40,6 +40,8 @@ if os.name == 'nt':
|
||||
import pywintypes
|
||||
|
||||
from openlp.core.lib import ScreenList
|
||||
from openlp.core.lib.ui import UiStrings, critical_error_message_box, translate
|
||||
from openlp.core.common import trace_error_handler
|
||||
from .presentationcontroller import PresentationController, PresentationDocument
|
||||
|
||||
|
||||
@ -99,7 +101,7 @@ class PowerpointController(PresentationController):
|
||||
if self.process.Presentations.Count > 0:
|
||||
return
|
||||
self.process.Quit()
|
||||
except pywintypes.com_error:
|
||||
except (AttributeError, pywintypes.com_error):
|
||||
pass
|
||||
self.process = None
|
||||
|
||||
@ -126,16 +128,24 @@ class PowerpointDocument(PresentationDocument):
|
||||
earlier.
|
||||
"""
|
||||
log.debug('load_presentation')
|
||||
if not self.controller.process or not self.controller.process.Visible:
|
||||
self.controller.start_process()
|
||||
try:
|
||||
if not self.controller.process or not self.controller.process.Visible:
|
||||
self.controller.start_process()
|
||||
self.controller.process.Presentations.Open(self.file_path, False, False, True)
|
||||
self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count)
|
||||
self.create_thumbnails()
|
||||
# Powerpoint 2013 pops up when loading a file, so we minimize it again
|
||||
if self.presentation.Application.Version == u'15.0':
|
||||
try:
|
||||
self.presentation.Application.WindowState = 2
|
||||
except:
|
||||
log.error('Failed to minimize main powerpoint window')
|
||||
trace_error_handler(log)
|
||||
return True
|
||||
except pywintypes.com_error:
|
||||
log.debug('PPT open failed')
|
||||
log.error('PPT open failed')
|
||||
trace_error_handler(log)
|
||||
return False
|
||||
self.presentation = self.controller.process.Presentations(self.controller.process.Presentations.Count)
|
||||
self.create_thumbnails()
|
||||
return True
|
||||
|
||||
def create_thumbnails(self):
|
||||
"""
|
||||
@ -206,23 +216,33 @@ class PowerpointDocument(PresentationDocument):
|
||||
Unblanks (restores) the presentation.
|
||||
"""
|
||||
log.debug('unblank_screen')
|
||||
self.presentation.SlideShowSettings.Run()
|
||||
self.presentation.SlideShowWindow.View.State = 1
|
||||
self.presentation.SlideShowWindow.Activate()
|
||||
if self.presentation.Application.Version == '14.0':
|
||||
# Unblanking is broken in PowerPoint 2010, need to redisplay
|
||||
slide = self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||
click = self.presentation.SlideShowWindow.View.GetClickIndex()
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(slide)
|
||||
if click:
|
||||
self.presentation.SlideShowWindow.View.GotoClick(click)
|
||||
try:
|
||||
self.presentation.SlideShowSettings.Run()
|
||||
self.presentation.SlideShowWindow.View.State = 1
|
||||
self.presentation.SlideShowWindow.Activate()
|
||||
if self.presentation.Application.Version == '14.0':
|
||||
# Unblanking is broken in PowerPoint 2010, need to redisplay
|
||||
slide = self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||
click = self.presentation.SlideShowWindow.View.GetClickIndex()
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(slide)
|
||||
if click:
|
||||
self.presentation.SlideShowWindow.View.GotoClick(click)
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in unblank_screen')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
|
||||
def blank_screen(self):
|
||||
"""
|
||||
Blanks the screen.
|
||||
"""
|
||||
log.debug('blank_screen')
|
||||
self.presentation.SlideShowWindow.View.State = 3
|
||||
try:
|
||||
self.presentation.SlideShowWindow.View.State = 3
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in blank_screen')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
|
||||
def is_blank(self):
|
||||
"""
|
||||
@ -230,7 +250,12 @@ class PowerpointDocument(PresentationDocument):
|
||||
"""
|
||||
log.debug('is_blank')
|
||||
if self.is_active():
|
||||
return self.presentation.SlideShowWindow.View.State == 3
|
||||
try:
|
||||
return self.presentation.SlideShowWindow.View.State == 3
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in is_blank')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
else:
|
||||
return False
|
||||
|
||||
@ -239,7 +264,12 @@ class PowerpointDocument(PresentationDocument):
|
||||
Stops the current presentation and hides the output.
|
||||
"""
|
||||
log.debug('stop_presentation')
|
||||
self.presentation.SlideShowWindow.View.Exit()
|
||||
try:
|
||||
self.presentation.SlideShowWindow.View.Exit()
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in stop_presentation')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
|
||||
if os.name == 'nt':
|
||||
def start_presentation(self):
|
||||
@ -259,24 +289,49 @@ class PowerpointDocument(PresentationDocument):
|
||||
ppt_window = self.presentation.SlideShowSettings.Run()
|
||||
if not ppt_window:
|
||||
return
|
||||
ppt_window.Top = size.y() * 72 / dpi
|
||||
ppt_window.Height = size.height() * 72 / dpi
|
||||
ppt_window.Left = size.x() * 72 / dpi
|
||||
ppt_window.Width = size.width() * 72 / dpi
|
||||
try:
|
||||
ppt_window.Top = size.y() * 72 / dpi
|
||||
ppt_window.Height = size.height() * 72 / dpi
|
||||
ppt_window.Left = size.x() * 72 / dpi
|
||||
ppt_window.Width = size.width() * 72 / dpi
|
||||
except AttributeError as e:
|
||||
log.error('AttributeError while in start_presentation')
|
||||
log.error(e)
|
||||
# Powerpoint 2013 pops up when starting a file, so we minimize it again
|
||||
if self.presentation.Application.Version == u'15.0':
|
||||
try:
|
||||
self.presentation.Application.WindowState = 2
|
||||
except:
|
||||
log.error('Failed to minimize main powerpoint window')
|
||||
trace_error_handler(log)
|
||||
|
||||
def get_slide_number(self):
|
||||
"""
|
||||
Returns the current slide number.
|
||||
"""
|
||||
log.debug('get_slide_number')
|
||||
return self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||
ret = 0
|
||||
try:
|
||||
ret = self.presentation.SlideShowWindow.View.CurrentShowPosition
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in get_slide_number')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
return ret
|
||||
|
||||
def get_slide_count(self):
|
||||
"""
|
||||
Returns total number of slides.
|
||||
"""
|
||||
log.debug('get_slide_count')
|
||||
return self.presentation.Slides.Count
|
||||
ret = 0
|
||||
try:
|
||||
ret = self.presentation.Slides.Count
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in get_slide_count')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
return ret
|
||||
|
||||
def goto_slide(self, slide_no):
|
||||
"""
|
||||
@ -285,14 +340,25 @@ class PowerpointDocument(PresentationDocument):
|
||||
:param slide_no: The slide the text is required for, starting at 1
|
||||
"""
|
||||
log.debug('goto_slide')
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(slide_no)
|
||||
try:
|
||||
self.presentation.SlideShowWindow.View.GotoSlide(slide_no)
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in goto_slide')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
|
||||
def next_step(self):
|
||||
"""
|
||||
Triggers the next effect of slide on the running presentation.
|
||||
"""
|
||||
log.debug('next_step')
|
||||
self.presentation.SlideShowWindow.View.Next()
|
||||
try:
|
||||
self.presentation.SlideShowWindow.View.Next()
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in next_step')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
return
|
||||
if self.get_slide_number() > self.get_slide_count():
|
||||
self.previous_step()
|
||||
|
||||
@ -301,7 +367,12 @@ class PowerpointDocument(PresentationDocument):
|
||||
Triggers the previous slide on the running presentation.
|
||||
"""
|
||||
log.debug('previous_step')
|
||||
self.presentation.SlideShowWindow.View.Previous()
|
||||
try:
|
||||
self.presentation.SlideShowWindow.View.Previous()
|
||||
except pywintypes.com_error:
|
||||
log.error('COM error while in previous_step')
|
||||
trace_error_handler(log)
|
||||
self.show_error_msg()
|
||||
|
||||
def get_slide_text(self, slide_no):
|
||||
"""
|
||||
@ -319,6 +390,16 @@ class PowerpointDocument(PresentationDocument):
|
||||
"""
|
||||
return _get_text_from_shapes(self.presentation.Slides(slide_no).NotesPage.Shapes)
|
||||
|
||||
def show_error_msg(self):
|
||||
"""
|
||||
Stop presentation and display an error message.
|
||||
"""
|
||||
self.stop_presentation()
|
||||
critical_error_message_box(UiStrings().Error, translate('PresentationPlugin.PowerpointDocument',
|
||||
'An error occurred in the Powerpoint integration '
|
||||
'and the presentation will be stopped. '
|
||||
'Restart the presentation if you wish to present it.'))
|
||||
|
||||
|
||||
def _get_text_from_shapes(shapes):
|
||||
"""
|
||||
|
@ -44,7 +44,7 @@ from openlp.core.lib.ui import set_case_insensitive_completer, critical_error_me
|
||||
from openlp.plugins.songs.lib import VerseType, clean_song
|
||||
from openlp.plugins.songs.lib.db import Book, Song, Author, AuthorType, Topic, MediaFile
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||
from openlp.plugins.songs.forms.editsongdialog import Ui_EditSongDialog
|
||||
from openlp.plugins.songs.forms.editverseform import EditVerseForm
|
||||
from openlp.plugins.songs.forms.mediafilesform import MediaFilesForm
|
||||
|
@ -33,7 +33,7 @@ from PyQt4 import QtCore, QtGui
|
||||
|
||||
from openlp.core.lib import build_icon
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||
|
||||
|
||||
class SongReviewWidget(QtGui.QWidget):
|
||||
|
@ -34,22 +34,23 @@ import logging
|
||||
|
||||
from openlp.core.common import translate, UiStrings
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from .opensongimport import OpenSongImport
|
||||
from .easyslidesimport import EasySlidesImport
|
||||
from .olpimport import OpenLPSongImport
|
||||
from .openlyricsimport import OpenLyricsImport
|
||||
from .wowimport import WowImport
|
||||
from .cclifileimport import CCLIFileImport
|
||||
from .dreambeamimport import DreamBeamImport
|
||||
from .powersongimport import PowerSongImport
|
||||
from .ewimport import EasyWorshipSongImport
|
||||
from .songbeamerimport import SongBeamerImport
|
||||
from .songshowplusimport import SongShowPlusImport
|
||||
from .songproimport import SongProImport
|
||||
from .sundayplusimport import SundayPlusImport
|
||||
from .foilpresenterimport import FoilPresenterImport
|
||||
from .zionworximport import ZionWorxImport
|
||||
from .propresenterimport import ProPresenterImport
|
||||
from .importers.opensong import OpenSongImport
|
||||
from .importers.easyslides import EasySlidesImport
|
||||
from .importers.openlp import OpenLPSongImport
|
||||
from .importers.openlyrics import OpenLyricsImport
|
||||
from .importers.wordsofworship import WordsOfWorshipImport
|
||||
from .importers.cclifile import CCLIFileImport
|
||||
from .importers.dreambeam import DreamBeamImport
|
||||
from .importers.powersong import PowerSongImport
|
||||
from .importers.easyworship import EasyWorshipSongImport
|
||||
from .importers.songbeamer import SongBeamerImport
|
||||
from .importers.songshowplus import SongShowPlusImport
|
||||
from .importers.songpro import SongProImport
|
||||
from .importers.sundayplus import SundayPlusImport
|
||||
from .importers.foilpresenter import FoilPresenterImport
|
||||
from .importers.zionworx import ZionWorxImport
|
||||
from .importers.propresenter import ProPresenterImport
|
||||
from .importers.worshipassistant import WorshipAssistantImport
|
||||
# Imports that might fail
|
||||
|
||||
|
||||
@ -57,13 +58,13 @@ log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
try:
|
||||
from .sofimport import SofImport
|
||||
from .importers.songsoffellowship import SongsOfFellowshipImport
|
||||
HAS_SOF = True
|
||||
except ImportError:
|
||||
log.exception('Error importing %s', 'SofImport')
|
||||
log.exception('Error importing %s', 'SongsOfFellowshipImport')
|
||||
HAS_SOF = False
|
||||
try:
|
||||
from .oooimport import OooImport
|
||||
from .importers.openoffice import OpenOfficeImport
|
||||
HAS_OOO = True
|
||||
except ImportError:
|
||||
log.exception('Error importing %s', 'OooImport')
|
||||
@ -71,14 +72,14 @@ except ImportError:
|
||||
HAS_MEDIASHOUT = False
|
||||
if os.name == 'nt':
|
||||
try:
|
||||
from .mediashoutimport import MediaShoutImport
|
||||
from .importers.mediashout import MediaShoutImport
|
||||
HAS_MEDIASHOUT = True
|
||||
except ImportError:
|
||||
log.exception('Error importing %s', 'MediaShoutImport')
|
||||
HAS_WORSHIPCENTERPRO = False
|
||||
if os.name == 'nt':
|
||||
try:
|
||||
from .worshipcenterproimport import WorshipCenterProImport
|
||||
from .importers.worshipcenterpro import WorshipCenterProImport
|
||||
HAS_WORSHIPCENTERPRO = True
|
||||
except ImportError:
|
||||
log.exception('Error importing %s', 'WorshipCenterProImport')
|
||||
@ -108,7 +109,7 @@ class SongFormat(object):
|
||||
Name of the format, e.g. ``'OpenLyrics'``
|
||||
|
||||
``'prefix'``
|
||||
Prefix for Qt objects. Use mixedCase, e.g. ``'open_lyrics'``
|
||||
Prefix for Qt objects. Use mixedCase, e.g. ``'openLyrics'``
|
||||
See ``SongImportForm.add_file_select_item()``
|
||||
|
||||
Optional attributes for each song format:
|
||||
@ -167,8 +168,9 @@ class SongFormat(object):
|
||||
SongsOfFellowship = 16
|
||||
SundayPlus = 17
|
||||
WordsOfWorship = 18
|
||||
WorshipCenterPro = 19
|
||||
ZionWorx = 20
|
||||
WorshipAssistant = 19
|
||||
WorshipCenterPro = 20
|
||||
ZionWorx = 21
|
||||
|
||||
# Set optional attribute defaults
|
||||
__defaults__ = {
|
||||
@ -188,7 +190,7 @@ class SongFormat(object):
|
||||
OpenLyrics: {
|
||||
'class': OpenLyricsImport,
|
||||
'name': 'OpenLyrics',
|
||||
'prefix': 'open_lyrics',
|
||||
'prefix': 'openLyrics',
|
||||
'filter': '%s (*.xml)' % translate('SongsPlugin.ImportWizardForm', 'OpenLyrics Files'),
|
||||
'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'OpenLyrics or OpenLP 2.0 Exported Song')
|
||||
},
|
||||
@ -316,11 +318,21 @@ class SongFormat(object):
|
||||
'filter': '%s (*.ptf)' % translate('SongsPlugin.ImportWizardForm', 'SundayPlus Song Files')
|
||||
},
|
||||
WordsOfWorship: {
|
||||
'class': WowImport,
|
||||
'class': WordsOfWorshipImport,
|
||||
'name': 'Words of Worship',
|
||||
'prefix': 'wordsOfWorship',
|
||||
'filter': '%s (*.wsg *.wow-song)' % translate('SongsPlugin.ImportWizardForm', 'Words Of Worship Song Files')
|
||||
},
|
||||
WorshipAssistant: {
|
||||
'class': WorshipAssistantImport,
|
||||
'name': 'Worship Assistant 0',
|
||||
'prefix': 'worshipAssistant',
|
||||
'selectMode': SongFormatSelect.SingleFile,
|
||||
'filter': '%s (*.csv)' % translate('SongsPlugin.ImportWizardForm', 'Worship Assistant Files'),
|
||||
'comboBoxText': translate('SongsPlugin.ImportWizardForm', 'Worship Assistant (CSV)'),
|
||||
'descriptionText': translate('SongsPlugin.ImportWizardForm',
|
||||
'In Worship Assistant, export your Database to a CSV file.')
|
||||
},
|
||||
WorshipCenterPro: {
|
||||
'name': 'WorshipCenter Pro',
|
||||
'prefix': 'worshipCenterPro',
|
||||
@ -370,16 +382,17 @@ class SongFormat(object):
|
||||
SongFormat.SongsOfFellowship,
|
||||
SongFormat.SundayPlus,
|
||||
SongFormat.WordsOfWorship,
|
||||
SongFormat.WorshipAssistant,
|
||||
SongFormat.WorshipCenterPro,
|
||||
SongFormat.ZionWorx
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def get(format, *attributes):
|
||||
def get(song_format, *attributes):
|
||||
"""
|
||||
Return requested song format attribute(s).
|
||||
|
||||
:param format: A song format from SongFormat.
|
||||
:param song_format: A song format from SongFormat.
|
||||
:param attributes: Zero or more song format attributes from SongFormat.
|
||||
|
||||
Return type depends on number of supplied attributes:
|
||||
@ -389,31 +402,31 @@ class SongFormat(object):
|
||||
:>1: Return tuple of requested attribute values.
|
||||
"""
|
||||
if not attributes:
|
||||
return SongFormat.__attributes__.get(format)
|
||||
return SongFormat.__attributes__.get(song_format)
|
||||
elif len(attributes) == 1:
|
||||
default = SongFormat.__defaults__.get(attributes[0])
|
||||
return SongFormat.__attributes__[format].get(attributes[0], default)
|
||||
return SongFormat.__attributes__[song_format].get(attributes[0], default)
|
||||
else:
|
||||
values = []
|
||||
for attr in attributes:
|
||||
default = SongFormat.__defaults__.get(attr)
|
||||
values.append(SongFormat.__attributes__[format].get(attr, default))
|
||||
values.append(SongFormat.__attributes__[song_format].get(attr, default))
|
||||
return tuple(values)
|
||||
|
||||
@staticmethod
|
||||
def set(format, attribute, value):
|
||||
def set(song_format, attribute, value):
|
||||
"""
|
||||
Set specified song format attribute to the supplied value.
|
||||
"""
|
||||
SongFormat.__attributes__[format][attribute] = value
|
||||
SongFormat.__attributes__[song_format][attribute] = value
|
||||
|
||||
|
||||
SongFormat.set(SongFormat.SongsOfFellowship, 'availability', HAS_SOF)
|
||||
if HAS_SOF:
|
||||
SongFormat.set(SongFormat.SongsOfFellowship, 'class', SofImport)
|
||||
SongFormat.set(SongFormat.SongsOfFellowship, 'class', SongsOfFellowshipImport)
|
||||
SongFormat.set(SongFormat.Generic, 'availability', HAS_OOO)
|
||||
if HAS_OOO:
|
||||
SongFormat.set(SongFormat.Generic, 'class', OooImport)
|
||||
SongFormat.set(SongFormat.Generic, 'class', OpenOfficeImport)
|
||||
SongFormat.set(SongFormat.MediaShout, 'availability', HAS_MEDIASHOUT)
|
||||
if HAS_MEDIASHOUT:
|
||||
SongFormat.set(SongFormat.MediaShout, 'class', MediaShoutImport)
|
||||
|
31
openlp/plugins/songs/lib/importers/__init__.py
Normal file
31
openlp/plugins/songs/lib/importers/__init__.py
Normal file
@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2014 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`~openlp.plugins.songs.lib.import` module contains importers for the Songs plugin.
|
||||
"""
|
@ -64,7 +64,7 @@ class CCLIFileImport(SongImport):
|
||||
filename = str(filename)
|
||||
log.debug('Importing CCLI File: %s', filename)
|
||||
if os.path.isfile(filename):
|
||||
detect_file = open(filename, 'r')
|
||||
detect_file = open(filename, 'rb')
|
||||
detect_content = detect_file.read(2048)
|
||||
try:
|
||||
str(detect_content, 'utf-8')
|
@ -27,15 +27,14 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`dreambeamimport` module provides the functionality for importing
|
||||
DreamBeam songs into the OpenLP database.
|
||||
The :mod:`dreambeam` module provides the functionality for importing DreamBeam songs into the OpenLP database.
|
||||
"""
|
||||
import logging
|
||||
|
||||
from lxml import etree, objectify
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
|
||||
log = logging.getLogger(__name__)
|
@ -33,7 +33,7 @@ import re
|
||||
from lxml import etree, objectify
|
||||
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -27,8 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`ewimport` module provides the functionality for importing
|
||||
EasyWorship song databases into the current installation database.
|
||||
The :mod:`easyworship` module provides the functionality for importing EasyWorship song databases into OpenLP.
|
||||
"""
|
||||
|
||||
import os
|
@ -99,10 +99,10 @@ from lxml import etree, objectify
|
||||
from openlp.core.lib import translate
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib import clean_song, VerseType
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.db import Author, Book, Song, Topic
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -27,13 +27,13 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`mediashoutimport` module provides the functionality for importing
|
||||
The :mod:`mediashout` module provides the functionality for importing
|
||||
a MediaShout database into the OpenLP database.
|
||||
"""
|
||||
import pyodbc
|
||||
|
||||
from openlp.core.lib import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
VERSE_TAGS = ['V', 'C', 'B', 'O', 'P', 'I', 'E']
|
||||
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`olpimport` module provides the functionality for importing OpenLP
|
||||
The :mod:`openlp` module provides the functionality for importing OpenLP
|
||||
song databases into the current installation database.
|
||||
"""
|
||||
import logging
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`openlyricsimport` module provides the functionality for importing
|
||||
The :mod:`openlyrics` module provides the functionality for importing
|
||||
songs which are saved as OpenLyrics files.
|
||||
"""
|
||||
|
||||
@ -37,9 +37,9 @@ import os
|
||||
from lxml import etree
|
||||
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
from openlp.plugins.songs.lib.xml import OpenLyrics, OpenLyricsError
|
||||
from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics, OpenLyricsError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -52,7 +52,7 @@ except ImportError:
|
||||
PAGE_BOTH = 6
|
||||
|
||||
|
||||
class OooImport(SongImport):
|
||||
class OpenOfficeImport(SongImport):
|
||||
"""
|
||||
Import songs from Impress/Powerpoint docs using Impress
|
||||
"""
|
@ -35,7 +35,7 @@ from lxml.etree import Error, LxmlError
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
|
||||
log = logging.getLogger(__name__)
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`powersongimport` module provides the functionality for importing
|
||||
The :mod:`powersong` module provides the functionality for importing
|
||||
PowerSong songs into the OpenLP database.
|
||||
"""
|
||||
import logging
|
||||
@ -35,7 +35,7 @@ import fnmatch
|
||||
import os
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -90,7 +90,7 @@ class PowerSongImport(SongImport):
|
||||
"""
|
||||
Receive either a list of files or a folder (unicode) to import.
|
||||
"""
|
||||
from .importer import SongFormat
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
ps_string = SongFormat.get(SongFormat.PowerSong, 'name')
|
||||
if isinstance(self.import_source, str):
|
||||
if os.path.isdir(self.import_source):
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`propresenterimport` module provides the functionality for importing
|
||||
The :mod:`propresenter` module provides the functionality for importing
|
||||
ProPresenter song files into the current installation database.
|
||||
"""
|
||||
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`songbeamerimport` module provides the functionality for importing SongBeamer songs into the OpenLP database.
|
||||
The :mod:`songbeamer` module provides the functionality for importing SongBeamer songs into the OpenLP database.
|
||||
"""
|
||||
import chardet
|
||||
import codecs
|
||||
@ -36,7 +36,7 @@ import os
|
||||
import re
|
||||
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -39,7 +39,7 @@ from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib import clean_song, VerseType
|
||||
from openlp.plugins.songs.lib.db import Song, Author, Topic, Book, MediaFile
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -27,13 +27,13 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`songproimport` module provides the functionality for importing SongPro
|
||||
The :mod:`songpro` module provides the functionality for importing SongPro
|
||||
songs into the OpenLP database.
|
||||
"""
|
||||
import re
|
||||
|
||||
from openlp.plugins.songs.lib import strip_rtf
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
|
||||
class SongProImport(SongImport):
|
@ -27,7 +27,7 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`songshowplusimport` module provides the functionality for importing SongShow Plus songs into the OpenLP
|
||||
The :mod:`songshowplus` module provides the functionality for importing SongShow Plus songs into the OpenLP
|
||||
database.
|
||||
"""
|
||||
import chardet
|
||||
@ -38,7 +38,7 @@ import struct
|
||||
|
||||
from openlp.core.ui.wizard import WizardStrings
|
||||
from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
TITLE = 1
|
||||
AUTHOR = 2
|
@ -37,13 +37,13 @@ import logging
|
||||
import os
|
||||
import re
|
||||
|
||||
from .oooimport import OooImport
|
||||
from .openoffice import OpenOfficeImport
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
if os.name == 'nt':
|
||||
from .oooimport import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
||||
from .openoffice import PAGE_BEFORE, PAGE_AFTER, PAGE_BOTH
|
||||
RuntimeException = Exception
|
||||
else:
|
||||
try:
|
||||
@ -62,7 +62,7 @@ except ImportError:
|
||||
ITALIC = 2
|
||||
|
||||
|
||||
class SofImport(OooImport):
|
||||
class SongsOfFellowshipImport(OpenOfficeImport):
|
||||
"""
|
||||
Import songs provided on disks with the Songs of Fellowship music books
|
||||
VOLS1_2.RTF, sof3words.rtf and sof4words.rtf
|
||||
@ -83,7 +83,7 @@ class SofImport(OooImport):
|
||||
Initialise the class. Requires a songmanager class which is passed
|
||||
to SongImport for writing song to disk
|
||||
"""
|
||||
OooImport.__init__(self, manager, **kwargs)
|
||||
OpenOfficeImport.__init__(self, manager, **kwargs)
|
||||
self.song = False
|
||||
|
||||
def process_ooo_document(self):
|
@ -32,7 +32,7 @@ import re
|
||||
|
||||
from openlp.plugins.songs.lib import VerseType, retrieve_windows_encoding
|
||||
from openlp.plugins.songs.lib import strip_rtf
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
HOTKEY_TO_VERSE_TYPE = {
|
||||
'1': 'v1',
|
@ -27,24 +27,23 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`wowimport` module provides the functionality for importing Words of
|
||||
The :mod:`wordsofworship` module provides the functionality for importing Words of
|
||||
Worship songs into the OpenLP database.
|
||||
"""
|
||||
import os
|
||||
import logging
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
BLOCK_TYPES = ('V', 'C', 'B')
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class WowImport(SongImport):
|
||||
class WordsOfWorshipImport(SongImport):
|
||||
"""
|
||||
The :class:`WowImport` class provides the ability to import song files from
|
||||
Words of Worship.
|
||||
The :class:`WordsOfWorshipImport` class provides the ability to import song files from Words of Worship.
|
||||
|
||||
**Words Of Worship Song File Format:**
|
||||
|
171
openlp/plugins/songs/lib/importers/worshipassistant.py
Normal file
171
openlp/plugins/songs/lib/importers/worshipassistant.py
Normal file
@ -0,0 +1,171 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2014 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`worshipassistant` module provides the functionality for importing
|
||||
Worship Assistant songs into the OpenLP database.
|
||||
"""
|
||||
import chardet
|
||||
import csv
|
||||
import logging
|
||||
import re
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
EMPTY_STR = 'NULL'
|
||||
|
||||
|
||||
class WorshipAssistantImport(SongImport):
|
||||
"""
|
||||
The :class:`WorshipAssistantImport` class provides the ability to import songs
|
||||
from Worship Assistant, via a dump of the database to a CSV file.
|
||||
|
||||
The following fields are in the exported CSV file:
|
||||
|
||||
* ``SONGNR`` Song ID (Discarded by importer)
|
||||
* ``TITLE`` Song title
|
||||
* ``AUTHOR`` Song author.
|
||||
* ``COPYRIGHT`` Copyright information
|
||||
* ``FIRSTLINE`` Unknown (Discarded by importer)
|
||||
* ``PRIKEY`` Primary chord key (Discarded by importer)
|
||||
* ``ALTKEY`` Alternate chord key (Discarded by importer)
|
||||
* ``TEMPO`` Tempo (Discarded by importer)
|
||||
* ``FOCUS`` Unknown (Discarded by importer)
|
||||
* ``THEME`` Theme (Discarded by importer)
|
||||
* ``SCRIPTURE`` Associated scripture (Discarded by importer)
|
||||
* ``ACTIVE`` Boolean value (Discarded by importer)
|
||||
* ``SONGBOOK`` Boolean value (Discarded by importer)
|
||||
* ``TIMESIG`` Unknown (Discarded by importer)
|
||||
* ``INTRODUCED`` Date the song was created (Discarded by importer)
|
||||
* ``LASTUSED`` Date the song was last used (Discarded by importer)
|
||||
* ``TIMESUSED`` How many times the song was used (Discarded by importer)
|
||||
* ``CCLINR`` CCLI Number
|
||||
* ``USER1`` User Field 1 (Discarded by importer)
|
||||
* ``USER2`` User Field 2 (Discarded by importer)
|
||||
* ``USER3`` User Field 3 (Discarded by importer)
|
||||
* ``USER4`` User Field 4 (Discarded by importer)
|
||||
* ``USER5`` User Field 5 (Discarded by importer)
|
||||
* ``ROADMAP`` Verse order used for the presentation
|
||||
* ``FILELINK1`` Associated file 1 (Discarded by importer)
|
||||
* ``OVERMAP`` Verse order used for printing (Discarded by importer)
|
||||
* ``FILELINK2`` Associated file 2 (Discarded by importer)
|
||||
* ``LYRICS`` The song lyrics used for printing (Discarded by importer, LYRICS2 is used instead)
|
||||
* ``INFO`` Unknown (Discarded by importer)
|
||||
* ``LYRICS2`` The song lyrics used for the presentation
|
||||
* ``BACKGROUND`` Custom background (Discarded by importer)
|
||||
"""
|
||||
def do_import(self):
|
||||
"""
|
||||
Receive a CSV file to import.
|
||||
"""
|
||||
# Get encoding
|
||||
detect_file = open(self.import_source, 'rb')
|
||||
detect_content = detect_file.read()
|
||||
details = chardet.detect(detect_content)
|
||||
detect_file.close()
|
||||
songs_file = open(self.import_source, 'r', encoding=details['encoding'])
|
||||
songs_reader = csv.DictReader(songs_file)
|
||||
try:
|
||||
records = list(songs_reader)
|
||||
except csv.Error as e:
|
||||
self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Error reading CSV file.'),
|
||||
translate('SongsPlugin.WorshipAssistantImport', 'Line %d: %s') %
|
||||
(songs_reader.line_num, e))
|
||||
return
|
||||
num_records = len(records)
|
||||
log.info('%s records found in CSV file' % num_records)
|
||||
self.import_wizard.progress_bar.setMaximum(num_records)
|
||||
for index, record in enumerate(records, 1):
|
||||
if self.stop_import_flag:
|
||||
return
|
||||
# Ensure that all keys are uppercase
|
||||
record = dict((field.upper(), value) for field, value in record.items())
|
||||
# The CSV file has a line in the middle of the file where the headers are repeated.
|
||||
# We need to skip this line.
|
||||
if record['TITLE'] == "TITLE" and record['AUTHOR'] == 'AUTHOR' and record['LYRICS2'] == 'LYRICS2':
|
||||
continue
|
||||
self.set_defaults()
|
||||
verse_order_list = []
|
||||
try:
|
||||
self.title = record['TITLE']
|
||||
if record['AUTHOR'] != EMPTY_STR:
|
||||
self.parse_author(record['AUTHOR'])
|
||||
print(record['AUTHOR'])
|
||||
if record['COPYRIGHT'] != EMPTY_STR:
|
||||
self.add_copyright(record['COPYRIGHT'])
|
||||
if record['CCLINR'] != EMPTY_STR:
|
||||
self.ccli_number = record['CCLINR']
|
||||
if record['ROADMAP'] != EMPTY_STR:
|
||||
verse_order_list = record['ROADMAP'].split(',')
|
||||
lyrics = record['LYRICS2']
|
||||
except UnicodeDecodeError as e:
|
||||
self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d' % index),
|
||||
translate('SongsPlugin.WorshipAssistantImport', 'Decoding error: %s') % e)
|
||||
continue
|
||||
except TypeError as e:
|
||||
self.log_error(translate('SongsPlugin.WorshipAssistantImport',
|
||||
'File not valid WorshipAssistant CSV format.'), 'TypeError: %s' % e)
|
||||
return
|
||||
verse = ''
|
||||
for line in lyrics.splitlines():
|
||||
if line.startswith('['): # verse marker
|
||||
# drop the square brackets
|
||||
right_bracket = line.find(']')
|
||||
content = line[1:right_bracket].lower()
|
||||
match = re.match('(\D*)(\d+)', content)
|
||||
if match is not None:
|
||||
verse_tag = match.group(1)
|
||||
verse_num = match.group(2)
|
||||
else:
|
||||
# otherwise we assume number 1 and take the whole prefix as the verse tag
|
||||
verse_tag = content
|
||||
verse_num = '1'
|
||||
verse_index = VerseType.from_loose_input(verse_tag) if verse_tag else 0
|
||||
verse_tag = VerseType.tags[verse_index]
|
||||
# Update verse order when the verse name has changed
|
||||
if content != verse_tag + verse_num:
|
||||
for i in range(len(verse_order_list)):
|
||||
if verse_order_list[i].lower() == content.lower():
|
||||
verse_order_list[i] = verse_tag + verse_num
|
||||
elif line and not line.isspace():
|
||||
verse += line + '\n'
|
||||
elif verse:
|
||||
self.add_verse(verse, verse_tag+verse_num)
|
||||
verse = ''
|
||||
if verse:
|
||||
self.add_verse(verse, verse_tag+verse_num)
|
||||
if verse_order_list:
|
||||
self.verse_order_list = verse_order_list
|
||||
if not self.finish():
|
||||
self.log_error(translate('SongsPlugin.WorshipAssistantImport', 'Record %d') % index
|
||||
+ (': "' + self.title + '"' if self.title else ''))
|
||||
songs_file.close()
|
@ -35,7 +35,7 @@ import logging
|
||||
import pyodbc
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -27,14 +27,13 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`zionworximport` module provides the functionality for importing
|
||||
ZionWorx songs into the OpenLP database.
|
||||
The :mod:`zionworx` module provides the functionality for importing ZionWorx songs into the OpenLP database.
|
||||
"""
|
||||
import csv
|
||||
import logging
|
||||
|
||||
from openlp.core.common import translate
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
@ -46,7 +46,7 @@ from openlp.plugins.songs.forms.songexportform import SongExportForm
|
||||
from openlp.plugins.songs.lib import VerseType, clean_string, delete_song
|
||||
from openlp.plugins.songs.lib.db import Author, AuthorType, Song, Book, MediaFile
|
||||
from openlp.plugins.songs.lib.ui import SongStrings
|
||||
from openlp.plugins.songs.lib.xml import OpenLyrics, SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics, SongXML
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -37,7 +37,7 @@ from lxml import etree
|
||||
|
||||
from openlp.core.common import RegistryProperties, check_directory_exists, translate
|
||||
from openlp.core.utils import clean_filename
|
||||
from openlp.plugins.songs.lib.xml import OpenLyrics
|
||||
from openlp.plugins.songs.lib.openlyricsxml import OpenLyrics
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
@ -38,7 +38,7 @@ from html.parser import HTMLParser
|
||||
from bs4 import BeautifulSoup, NavigableString
|
||||
|
||||
from openlp.plugins.songs.lib import Song, VerseType, clean_song, Author
|
||||
from openlp.plugins.songs.lib.xml import SongXML
|
||||
from openlp.plugins.songs.lib.openlyricsxml import SongXML
|
||||
|
||||
USER_AGENT = 'Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; GT-I9000 ' \
|
||||
'Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 ' \
|
||||
|
@ -49,7 +49,7 @@ from openlp.plugins.songs.lib import clean_song, upgrade
|
||||
from openlp.plugins.songs.lib.db import init_schema, Song
|
||||
from openlp.plugins.songs.lib.mediaitem import SongSearch
|
||||
from openlp.plugins.songs.lib.importer import SongFormat
|
||||
from openlp.plugins.songs.lib.olpimport import OpenLPSongImport
|
||||
from openlp.plugins.songs.lib.importers.openlp import OpenLPSongImport
|
||||
from openlp.plugins.songs.lib.mediaitem import SongMediaItem
|
||||
from openlp.plugins.songs.lib.songstab import SongsTab
|
||||
|
||||
|
@ -1,19 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Categories=AudioVideo;
|
||||
Comment[de]=
|
||||
Comment=
|
||||
Exec=openlp %F
|
||||
GenericName[de]=Church lyrics projection
|
||||
GenericName=Church lyrics projection
|
||||
Icon=openlp
|
||||
MimeType=application/x-openlp-service;
|
||||
Name[de]=OpenLP
|
||||
Name=OpenLP
|
||||
Path=
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Type=Application
|
||||
X-DBUS-ServiceName=
|
||||
X-DBUS-StartupType=
|
||||
X-KDE-SubstituteUID=false
|
||||
X-KDE-Username=
|
||||
|
8
setup.py
8
setup.py
@ -105,10 +105,12 @@ try:
|
||||
tag_version, tag_revision = tags[-1].split()
|
||||
# If they are equal, then this tree is tarball with the source for the release. We do not want the revision number
|
||||
# in the version string.
|
||||
tree_revision = tree_revision.strip()
|
||||
tag_revision = tag_revision.strip()
|
||||
if tree_revision == tag_revision:
|
||||
version_string = tag_version
|
||||
version_string = tag_version.decode('utf-8')
|
||||
else:
|
||||
version_string = '%s-bzr%s' % (tag_version, tree_revision)
|
||||
version_string = '%s-bzr%s' % (tag_version.decode('utf-8'), tree_revision.decode('utf-8'))
|
||||
ver_file = open(VERSION_FILE, 'w')
|
||||
ver_file.write(version_string)
|
||||
except:
|
||||
@ -152,7 +154,7 @@ using a computer and a data projector.""",
|
||||
'Operating System :: POSIX :: BSD :: FreeBSD',
|
||||
'Operating System :: POSIX :: Linux',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Topic :: Desktop Environment :: Gnome',
|
||||
'Topic :: Desktop Environment :: K Desktop Environment (KDE)',
|
||||
'Topic :: Multimedia',
|
||||
|
76
tests/functional/openlp_core_common/test_registrymixin.py
Normal file
76
tests/functional/openlp_core_common/test_registrymixin.py
Normal file
@ -0,0 +1,76 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2014 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
Package to test the openlp.core.common package.
|
||||
"""
|
||||
import os
|
||||
from unittest import TestCase
|
||||
|
||||
from openlp.core.common import RegistryMixin, Registry
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../', '..', 'resources'))
|
||||
|
||||
|
||||
class TestRegistryMixin(TestCase):
|
||||
|
||||
def registry_mixin_missing_test(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
# GIVEN: A new registry
|
||||
Registry.create()
|
||||
|
||||
# WHEN: I create a new class
|
||||
mock_1 = Test1()
|
||||
|
||||
# THEN: The following methods are missing
|
||||
self.assertEqual(len(Registry().functions_list), 0), 'The function should not be in the dict anymore.'
|
||||
|
||||
def registry_mixin_present_test(self):
|
||||
"""
|
||||
Test the registry creation and its usage
|
||||
"""
|
||||
# GIVEN: A new registry
|
||||
Registry.create()
|
||||
|
||||
# WHEN: I create a new class
|
||||
mock_2 = Test2()
|
||||
|
||||
# THEN: The following bootstrap methods should be present
|
||||
self.assertEqual(len(Registry().functions_list), 2), 'The bootstrap functions should be in the dict.'
|
||||
|
||||
|
||||
class Test1(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
class Test2(RegistryMixin):
|
||||
def __init__(self):
|
||||
super(Test2, self).__init__(None)
|
@ -65,16 +65,6 @@ class TestRenderer(TestCase):
|
||||
"""
|
||||
del self.screens
|
||||
|
||||
def initial_renderer_test(self):
|
||||
"""
|
||||
Test the initial renderer state
|
||||
"""
|
||||
# GIVEN: A new renderer instance.
|
||||
renderer = Renderer()
|
||||
# WHEN: the default renderer is built.
|
||||
# THEN: The renderer should be a live controller.
|
||||
self.assertEqual(renderer.is_live, True, 'The base renderer should be a live controller')
|
||||
|
||||
def default_screen_layout_test(self):
|
||||
"""
|
||||
Test the default layout calculations
|
||||
|
@ -0,0 +1,131 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2014 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2014 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
Functional tests to test the PowerPointController class and related methods.
|
||||
"""
|
||||
import os
|
||||
if os.name == 'nt':
|
||||
import pywintypes
|
||||
import shutil
|
||||
from unittest import TestCase
|
||||
from tempfile import mkdtemp
|
||||
|
||||
from tests.functional import patch, MagicMock
|
||||
from tests.helpers.testmixin import TestMixin
|
||||
|
||||
from openlp.plugins.presentations.lib.powerpointcontroller import PowerpointController, PowerpointDocument
|
||||
|
||||
|
||||
class TestPowerpointController(TestCase, TestMixin):
|
||||
"""
|
||||
Test the PowerpointController Class
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the patches and mocks need for all tests.
|
||||
"""
|
||||
self.get_application()
|
||||
self.build_settings()
|
||||
self.mock_plugin = MagicMock()
|
||||
self.temp_folder = mkdtemp()
|
||||
self.mock_plugin.settings_section = self.temp_folder
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Stop the patches
|
||||
"""
|
||||
self.destroy_settings()
|
||||
shutil.rmtree(self.temp_folder)
|
||||
|
||||
def constructor_test(self):
|
||||
"""
|
||||
Test the Constructor from the PowerpointController
|
||||
"""
|
||||
# GIVEN: No presentation controller
|
||||
controller = None
|
||||
|
||||
# WHEN: The presentation controller object is created
|
||||
controller = PowerpointController(plugin=self.mock_plugin)
|
||||
|
||||
# THEN: The name of the presentation controller should be correct
|
||||
self.assertEqual('Powerpoint', controller.name,
|
||||
'The name of the presentation controller should be correct')
|
||||
|
||||
|
||||
class TestPowerpointDocument(TestCase):
|
||||
"""
|
||||
Test the PowerpointDocument Class
|
||||
"""
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Set up the patches and mocks need for all tests.
|
||||
"""
|
||||
self.powerpoint_document_stop_presentation_patcher = patch(
|
||||
'openlp.plugins.presentations.lib.powerpointcontroller.PowerpointDocument.stop_presentation')
|
||||
self.presentation_document_get_temp_folder_patcher = patch(
|
||||
'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument.get_temp_folder')
|
||||
self.presentation_document_setup_patcher = patch(
|
||||
'openlp.plugins.presentations.lib.powerpointcontroller.PresentationDocument._setup')
|
||||
self.mock_powerpoint_document_stop_presentation = self.powerpoint_document_stop_presentation_patcher.start()
|
||||
self.mock_presentation_document_get_temp_folder = self.presentation_document_get_temp_folder_patcher.start()
|
||||
self.mock_presentation_document_setup = self.presentation_document_setup_patcher.start()
|
||||
self.mock_controller = MagicMock()
|
||||
self.mock_presentation = MagicMock()
|
||||
self.mock_presentation_document_get_temp_folder.return_value = 'temp folder'
|
||||
|
||||
def tearDown(self):
|
||||
"""
|
||||
Stop the patches
|
||||
"""
|
||||
self.powerpoint_document_stop_presentation_patcher.stop()
|
||||
self.presentation_document_get_temp_folder_patcher.stop()
|
||||
self.presentation_document_setup_patcher.stop()
|
||||
|
||||
def show_error_msg_test(self):
|
||||
"""
|
||||
Test the PowerpointDocument.show_error_msg() method gets called on com exception
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
# GIVEN: A PowerpointDocument with mocked controller and presentation
|
||||
with patch('openlp.plugins.presentations.lib.powerpointcontroller.critical_error_message_box') as \
|
||||
mocked_critical_error_message_box:
|
||||
instance = PowerpointDocument(self.mock_controller, self.mock_presentation)
|
||||
instance.presentation = MagicMock()
|
||||
instance.presentation.SlideShowWindow.View.GotoSlide = MagicMock(side_effect=pywintypes.com_error('1'))
|
||||
|
||||
# WHEN: Calling goto_slide which will throw an exception
|
||||
instance.goto_slide(42)
|
||||
|
||||
# THEN: mocked_critical_error_message_box should have been called
|
||||
mocked_critical_error_message_box.assert_called_with('Error', 'An error occurred in the Powerpoint '
|
||||
'integration and the presentation will be stopped.'
|
||||
' Restart the presentation if you wish to '
|
||||
'present it.')
|
@ -35,7 +35,7 @@ from unittest import TestCase
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
|
||||
from openlp.plugins.songs.lib.ewimport import EasyWorshipSongImport, FieldDescEntry, FieldType
|
||||
from openlp.plugins.songs.lib.importers.easyworship import EasyWorshipSongImport, FieldDescEntry, FieldType
|
||||
|
||||
TEST_PATH = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'easyworshipsongs'))
|
||||
@ -178,7 +178,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test creating an instance of the EasyWorship file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
@ -192,7 +192,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test finding an existing field in a given list using the :mod:`find_field`
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions.
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.field_descriptions = TEST_FIELD_DESCS
|
||||
@ -210,7 +210,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test finding an non-existing field in a given list using the :mod:`find_field`
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager" and a list of field descriptions
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.field_descriptions = TEST_FIELD_DESCS
|
||||
@ -228,8 +228,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out struct class, and a mocked out "manager" and a list of
|
||||
# field descriptions
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
|
||||
@ -246,7 +246,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`get_field` module
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager", an encoding and some test data and known results
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.encoding = TEST_DATA_ENCODING
|
||||
@ -269,7 +269,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
"""
|
||||
for test_results in GET_MEMO_FIELD_TEST_RESULTS:
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager", a mocked out memo_file and an encoding
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_memo_file = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
@ -300,8 +300,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`do_import` module opens the correct files
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.side_effect = [True, False]
|
||||
@ -319,8 +319,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`do_import` module produces an error when Songs.MB not found.
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
importer.log_error = MagicMock()
|
||||
@ -339,8 +339,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`do_import` module handles invalid database files correctly
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, os.path and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path:
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.return_value = True
|
||||
@ -358,10 +358,10 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`do_import` module handles invalid memo files correctly
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path, \
|
||||
patch('builtins.open') as mocked_open, \
|
||||
patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct:
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
mocked_os_path.isfile.return_value = True
|
||||
@ -385,10 +385,10 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
Test the :mod:`do_import` converts the code page to the encoding correctly
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.os.path') as mocked_os_path, \
|
||||
patch('builtins.open'), patch('openlp.plugins.songs.lib.ewimport.struct') as mocked_struct, \
|
||||
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.os.path') as mocked_os_path, \
|
||||
patch('builtins.open'), patch('openlp.plugins.songs.lib.importers.easyworship.struct') as mocked_struct, \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') as \
|
||||
mocked_retrieve_windows_encoding:
|
||||
mocked_manager = MagicMock()
|
||||
importer = EasyWorshipSongImport(mocked_manager, filenames=[])
|
||||
@ -413,8 +413,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
|
||||
# GIVEN: Test files with a mocked out SongImport class, a mocked out "manager", a mocked out "import_wizard",
|
||||
# and mocked out "author", "add_copyright", "add_verse", "finish" methods.
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') as \
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') as \
|
||||
mocked_retrieve_windows_encoding:
|
||||
mocked_retrieve_windows_encoding.return_value = 'cp1252'
|
||||
mocked_manager = MagicMock()
|
||||
@ -469,8 +469,8 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
|
||||
# GIVEN: Test files with a mocked out SongImport class, a mocked out "manager", a mocked out "import_wizard",
|
||||
# and mocked out "author", "add_copyright", "add_verse", "finish" methods.
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.ewimport.retrieve_windows_encoding') \
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.easyworship.retrieve_windows_encoding') \
|
||||
as mocked_retrieve_windows_encoding:
|
||||
mocked_retrieve_windows_encoding.return_value = 'cp1252'
|
||||
mocked_manager = MagicMock()
|
||||
@ -509,7 +509,7 @@ class TestEasyWorshipSongImport(TestCase):
|
||||
"""
|
||||
|
||||
# GIVEN: A mocked out SongImport class, a mocked out "manager" and mocked out "author" method.
|
||||
with patch('openlp.plugins.songs.lib.ewimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.easyworship.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_add_author = MagicMock()
|
||||
importer = EasyWorshipSongImportLogger(mocked_manager)
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
from unittest import TestCase
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
from openlp.plugins.songs.lib.foilpresenterimport import FoilPresenter
|
||||
from openlp.plugins.songs.lib.importers.foilpresenter import FoilPresenter
|
||||
|
||||
TEST_PATH = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '..', '..', '..', '/resources/foilpresentersongs'))
|
||||
@ -57,27 +57,27 @@ class TestFoilPresenter(TestCase):
|
||||
# _process_topics
|
||||
|
||||
def setUp(self):
|
||||
self.child_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._child')
|
||||
self.clean_song_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.clean_song')
|
||||
self.objectify_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.objectify')
|
||||
self.child_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._child')
|
||||
self.clean_song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.clean_song')
|
||||
self.objectify_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.objectify')
|
||||
self.process_authors_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_authors')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_authors')
|
||||
self.process_cclinumber_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_cclinumber')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_cclinumber')
|
||||
self.process_comments_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_comments')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_comments')
|
||||
self.process_lyrics_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_lyrics')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_lyrics')
|
||||
self.process_songbooks_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_songbooks')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_songbooks')
|
||||
self.process_titles_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_titles')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_titles')
|
||||
self.process_topics_patcher = \
|
||||
patch('openlp.plugins.songs.lib.foilpresenterimport.FoilPresenter._process_topics')
|
||||
self.re_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.re')
|
||||
self.song_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.Song')
|
||||
self.song_xml_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.SongXML')
|
||||
self.translate_patcher = patch('openlp.plugins.songs.lib.foilpresenterimport.translate')
|
||||
patch('openlp.plugins.songs.lib.importers.foilpresenter.FoilPresenter._process_topics')
|
||||
self.re_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.re')
|
||||
self.song_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.Song')
|
||||
self.song_xml_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.SongXML')
|
||||
self.translate_patcher = patch('openlp.plugins.songs.lib.importers.foilpresenter.translate')
|
||||
|
||||
self.mocked_child = self.child_patcher.start()
|
||||
self.mocked_clean_song = self.clean_song_patcher.start()
|
||||
|
@ -34,8 +34,8 @@ import os
|
||||
from unittest import TestCase
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
from openlp.plugins.songs.lib.openlyricsimport import OpenLyricsImport
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.openlyrics import OpenLyricsImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..', '..', '..', 'resources', 'openlyricssongs'))
|
||||
@ -69,7 +69,7 @@ class TestOpenLyricsImport(TestCase):
|
||||
Test creating an instance of the OpenLyrics file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.openlyrics.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
from unittest import TestCase
|
||||
|
||||
from tests.helpers.songfileimport import SongImportTestHelper
|
||||
from openlp.plugins.songs.lib.opensongimport import OpenSongImport
|
||||
from openlp.plugins.songs.lib.importers.opensong import OpenSongImport
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
TEST_PATH = os.path.abspath(
|
||||
@ -45,18 +45,18 @@ class TestOpenSongFileImport(SongImportTestHelper):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.importer_class_name = 'OpenSongImport'
|
||||
self.importer_module_name = 'opensongimport'
|
||||
self.importer_module_name = 'opensong'
|
||||
super(TestOpenSongFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an OpenSong file works correctly on various files
|
||||
"""
|
||||
self.file_import(os.path.join(TEST_PATH, 'Amazing Grace'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
|
||||
self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
|
||||
self.file_import(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'One, Two, Three, Four, Five')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'One, Two, Three, Four, Five.json')))
|
||||
|
||||
|
||||
@ -69,7 +69,7 @@ class TestOpenSongImport(TestCase):
|
||||
Test creating an instance of the OpenSong file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.opensongimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
@ -83,7 +83,7 @@ class TestOpenSongImport(TestCase):
|
||||
Test OpenSongImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.opensongimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = OpenSongImport(mocked_manager, filenames=[])
|
||||
@ -104,7 +104,7 @@ class TestOpenSongImport(TestCase):
|
||||
Test OpenSongImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.opensongimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.opensong.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = OpenSongImport(mocked_manager, filenames=[])
|
||||
|
@ -43,12 +43,12 @@ class TestProPresenterFileImport(SongImportTestHelper):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.importer_class_name = 'ProPresenterImport'
|
||||
self.importer_module_name = 'propresenterimport'
|
||||
self.importer_module_name = 'propresenter'
|
||||
super(TestProPresenterFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an ProPresenter file works correctly
|
||||
"""
|
||||
self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.pro4'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.pro4')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
|
||||
|
@ -34,7 +34,7 @@ import os
|
||||
from unittest import TestCase
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
from openlp.plugins.songs.lib.songbeamerimport import SongBeamerImport
|
||||
from openlp.plugins.songs.lib.importers.songbeamer import SongBeamerImport
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
|
||||
TEST_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
@ -64,7 +64,7 @@ class TestSongBeamerImport(TestCase):
|
||||
Test creating an instance of the SongBeamer file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
@ -78,7 +78,7 @@ class TestSongBeamerImport(TestCase):
|
||||
Test SongBeamerImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
@ -99,7 +99,7 @@ class TestSongBeamerImport(TestCase):
|
||||
Test SongBeamerImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongBeamerImport(mocked_manager, filenames=[])
|
||||
@ -122,7 +122,7 @@ class TestSongBeamerImport(TestCase):
|
||||
|
||||
# GIVEN: Test files with a mocked out SongImport class, a mocked out "manager", a mocked out "import_wizard",
|
||||
# and mocked out "author", "add_copyright", "add_verse", "finish" methods.
|
||||
with patch('openlp.plugins.songs.lib.songbeamerimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songbeamer.SongImport'):
|
||||
for song_file in SONG_TEST_DATA:
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
|
@ -35,7 +35,7 @@ from unittest import TestCase
|
||||
|
||||
from tests.helpers.songfileimport import SongImportTestHelper
|
||||
from openlp.plugins.songs.lib import VerseType
|
||||
from openlp.plugins.songs.lib.songshowplusimport import SongShowPlusImport
|
||||
from openlp.plugins.songs.lib.importers.songshowplus import SongShowPlusImport
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
TEST_PATH = os.path.abspath(
|
||||
@ -46,18 +46,18 @@ class TestSongShowPlusFileImport(SongImportTestHelper):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.importer_class_name = 'SongShowPlusImport'
|
||||
self.importer_module_name = 'songshowplusimport'
|
||||
self.importer_module_name = 'songshowplus'
|
||||
super(TestSongShowPlusFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading a SongShow Plus file works correctly on various files
|
||||
"""
|
||||
self.file_import(os.path.join(TEST_PATH, 'Amazing Grace.sbsong'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'Amazing Grace.sbsong')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Amazing Grace.json')))
|
||||
self.file_import(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.sbsong')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'Beautiful Garden Of Prayer.json')))
|
||||
self.file_import(os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong'),
|
||||
self.file_import([os.path.join(TEST_PATH, 'a mighty fortress is our god.sbsong')],
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'a mighty fortress is our god.json')))
|
||||
|
||||
|
||||
@ -70,7 +70,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
Test creating an instance of the SongShow Plus file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
@ -84,7 +84,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
Test SongShowPlusImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
@ -105,7 +105,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
Test SongShowPlusImport.do_import handles different invalid import_source values
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
@ -126,7 +126,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
Test to_openlp_verse_tag method by simulating adding a verse
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
|
||||
@ -154,7 +154,7 @@ class TestSongShowPlusImport(TestCase):
|
||||
Test to_openlp_verse_tag method by simulating adding a verse to the verse order
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.songshowplusimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.songshowplus.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
importer = SongShowPlusImport(mocked_manager, filenames=[])
|
||||
|
||||
|
@ -0,0 +1,56 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2013 Raoul Snyman #
|
||||
# Portions copyright (c) 2008-2013 Tim Bentley, Gerald Britton, Jonathan #
|
||||
# Corwin, Samuel Findlay, Michael Gorven, Scott Guerrieri, Matthias Hub, #
|
||||
# Meinert Jordan, Armin Köhler, Erik Lundin, Edwin Lunando, Brian T. Meyer. #
|
||||
# Joshua Miller, Stevan Pettit, Andreas Preikschat, Mattias Põldaru, #
|
||||
# Christian Richter, Philip Ridout, Simon Scudder, Jeffrey Smith, #
|
||||
# Maikel Stuivenberg, Martin Thompson, Jon Tibble, Dave Warnock, #
|
||||
# Frode Woldsund, Martin Zibricky, Patrick Zimmermann #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
"""
|
||||
The :mod:`worshipassistantimport` module provides the functionality for importing
|
||||
WorshipAssistant song files into the current installation database.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from tests.helpers.songfileimport import SongImportTestHelper
|
||||
|
||||
TEST_PATH = os.path.abspath(
|
||||
os.path.join(os.path.dirname(__file__), '..', '..', '..', 'resources', 'worshipassistantsongs'))
|
||||
|
||||
|
||||
class TestWorshipAssistantFileImport(SongImportTestHelper):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.importer_class_name = 'WorshipAssistantImport'
|
||||
self.importer_module_name = 'worshipassistant'
|
||||
super(TestWorshipAssistantFileImport, self).__init__(*args, **kwargs)
|
||||
|
||||
def test_song_import(self):
|
||||
"""
|
||||
Test that loading an Worship Assistant file works correctly
|
||||
"""
|
||||
self.file_import(os.path.join(TEST_PATH, 'du_herr.csv'),
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'du_herr.json')))
|
||||
self.file_import(os.path.join(TEST_PATH, 'would_you_be_free.csv'),
|
||||
self.load_external_result_data(os.path.join(TEST_PATH, 'would_you_be_free.json')))
|
@ -37,7 +37,7 @@ if os.name != 'nt':
|
||||
|
||||
import pyodbc
|
||||
|
||||
from openlp.plugins.songs.lib.worshipcenterproimport import WorshipCenterProImport
|
||||
from openlp.plugins.songs.lib.importers.worshipcenterpro import WorshipCenterProImport
|
||||
from tests.functional import patch, MagicMock
|
||||
|
||||
|
||||
@ -141,7 +141,7 @@ class TestWorshipCenterProSongImport(TestCase):
|
||||
Test creating an instance of the WorshipCenter Pro file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
@ -156,9 +156,10 @@ class TestWorshipCenterProSongImport(TestCase):
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out pyodbc module, a mocked out translate method,
|
||||
# a mocked "manager" and a mocked out log_error method.
|
||||
with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.worshipcenterproimport.pyodbc.connect') as mocked_pyodbc_connect, \
|
||||
patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate:
|
||||
with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.worshipcenterpro.pyodbc.connect') \
|
||||
as mocked_pyodbc_connect, \
|
||||
patch('openlp.plugins.songs.lib.importers.worshipcenterpro.translate') as mocked_translate:
|
||||
mocked_manager = MagicMock()
|
||||
mocked_log_error = MagicMock()
|
||||
mocked_translate.return_value = 'Translated Text'
|
||||
@ -185,9 +186,9 @@ class TestWorshipCenterProSongImport(TestCase):
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, a mocked out pyodbc module with a simulated recordset, a mocked out
|
||||
# translate method, a mocked "manager", add_verse method & mocked_finish method.
|
||||
with patch('openlp.plugins.songs.lib.worshipcenterproimport.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.worshipcenterproimport.pyodbc') as mocked_pyodbc, \
|
||||
patch('openlp.plugins.songs.lib.worshipcenterproimport.translate') as mocked_translate:
|
||||
with patch('openlp.plugins.songs.lib.importers.worshipcenterpro.SongImport'), \
|
||||
patch('openlp.plugins.songs.lib.importers.worshipcenterpro.pyodbc') as mocked_pyodbc, \
|
||||
patch('openlp.plugins.songs.lib.importers.worshipcenterpro.translate') as mocked_translate:
|
||||
mocked_manager = MagicMock()
|
||||
mocked_import_wizard = MagicMock()
|
||||
mocked_add_verse = MagicMock()
|
||||
|
@ -33,8 +33,8 @@ This module contains tests for the ZionWorx song importer.
|
||||
from unittest import TestCase
|
||||
|
||||
from tests.functional import MagicMock, patch
|
||||
from openlp.plugins.songs.lib.zionworximport import ZionWorxImport
|
||||
from openlp.plugins.songs.lib.songimport import SongImport
|
||||
from openlp.plugins.songs.lib.importers.zionworx import ZionWorxImport
|
||||
from openlp.plugins.songs.lib.importers.songimport import SongImport
|
||||
|
||||
|
||||
class TestZionWorxImport(TestCase):
|
||||
@ -46,7 +46,7 @@ class TestZionWorxImport(TestCase):
|
||||
Test creating an instance of the ZionWorx file importer
|
||||
"""
|
||||
# GIVEN: A mocked out SongImport class, and a mocked out "manager"
|
||||
with patch('openlp.plugins.songs.lib.zionworximport.SongImport'):
|
||||
with patch('openlp.plugins.songs.lib.importers.zionworx.SongImport'):
|
||||
mocked_manager = MagicMock()
|
||||
|
||||
# WHEN: An importer object is created
|
||||
|
@ -42,23 +42,24 @@ class SongImportTestHelper(TestCase):
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(SongImportTestHelper, self).__init__(*args, **kwargs)
|
||||
self.importer_module = __import__(
|
||||
'openlp.plugins.songs.lib.%s' % self.importer_module_name, fromlist=[self.importer_class_name])
|
||||
self.importer_module = __import__('openlp.plugins.songs.lib.importers.%s' %
|
||||
self.importer_module_name, fromlist=[self.importer_class_name])
|
||||
self.importer_class = getattr(self.importer_module, self.importer_class_name)
|
||||
|
||||
def setUp(self):
|
||||
"""
|
||||
Patch and set up the mocks required.
|
||||
"""
|
||||
self.add_copyright_patcher = patch(
|
||||
'openlp.plugins.songs.lib.%s.%s.add_copyright' % (self.importer_module_name, self.importer_class_name))
|
||||
self.add_verse_patcher = patch(
|
||||
'openlp.plugins.songs.lib.%s.%s.add_verse' % (self.importer_module_name, self.importer_class_name))
|
||||
self.finish_patcher = patch(
|
||||
'openlp.plugins.songs.lib.%s.%s.finish' % (self.importer_module_name, self.importer_class_name))
|
||||
self.add_author_patcher = patch(
|
||||
'openlp.plugins.songs.lib.%s.%s.add_author' % (self.importer_module_name, self.importer_class_name))
|
||||
self.song_import_patcher = patch('openlp.plugins.songs.lib.%s.SongImport' % self.importer_module_name)
|
||||
self.add_copyright_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_copyright' %
|
||||
(self.importer_module_name, self.importer_class_name))
|
||||
self.add_verse_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_verse' %
|
||||
(self.importer_module_name, self.importer_class_name))
|
||||
self.finish_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.finish' %
|
||||
(self.importer_module_name, self.importer_class_name))
|
||||
self.add_author_patcher = patch('openlp.plugins.songs.lib.importers.%s.%s.add_author' %
|
||||
(self.importer_module_name, self.importer_class_name))
|
||||
self.song_import_patcher = patch('openlp.plugins.songs.lib.importers.%s.SongImport' %
|
||||
self.importer_module_name)
|
||||
self.mocked_add_copyright = self.add_copyright_patcher.start()
|
||||
self.mocked_add_verse = self.add_verse_patcher.start()
|
||||
self.mocked_finish = self.finish_patcher.start()
|
||||
@ -95,7 +96,7 @@ class SongImportTestHelper(TestCase):
|
||||
importer.topics = []
|
||||
|
||||
# WHEN: Importing the source file
|
||||
importer.import_source = [source_file_name]
|
||||
importer.import_source = source_file_name
|
||||
add_verse_calls = self._get_data(result_data, 'verses')
|
||||
author_calls = self._get_data(result_data, 'authors')
|
||||
ccli_number = self._get_data(result_data, 'ccli_number')
|
||||
|
30
tests/resources/worshipassistantsongs/du_herr.csv
Normal file
30
tests/resources/worshipassistantsongs/du_herr.csv
Normal file
@ -0,0 +1,30 @@
|
||||
"SongID","SongNr","Title","Author","Copyright","FirstLine","PriKey","AltKey","Tempo","Focus","Theme","Scripture","Active","Songbook","TimeSig","Introduced","LastUsed","TimesUsed","CCLINr","User1","User2","User3","User4","User5","Roadmap","Overmap","FileLink1","FileLink2","Updated","Lyrics","Info","Lyrics2","Background"
|
||||
"4ee399dc-edda-4aa9-891e-a859ca093c78","NULL","Du, Herr, verläßt mich nicht","Carl Brockhaus / Johann Georg Bäßler 1806","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","1","1","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","NULL","2014-06-25 12:15:28.317","","NULL","[1]
|
||||
Du, Herr, verläßt mich nicht.
|
||||
Auf Dich mein Herz allein vertraut,
|
||||
Mein Auge glaubend auf Dich schaut.
|
||||
Du bist mein Heil, mein Licht,
|
||||
Mein Fels, mein sichrer Hort.
|
||||
Bin ich versucht, gibt's Not und Leid,
|
||||
Du bleibst mein Trost, mein Arm im Streit,
|
||||
Mein Licht am dunklen Ort.
|
||||
|
||||
[2]
|
||||
Ich weiß, daß Du mich liebst.
|
||||
Bist mir in jeder Lage nah',
|
||||
Wohin ich gehe – Du bist da,
|
||||
Ja, Du mir alles gibst.
|
||||
Ich überlaß mich Dir;
|
||||
Denn Du, Herr, kennst mich ganz und gar
|
||||
Und führst mich sicher, wunderbar,
|
||||
Und bist selbst alles mir.
|
||||
|
||||
[3]
|
||||
In dieser Wüste hier
|
||||
Find't nirgend meine Seele Ruh',
|
||||
Denn meine Ruh' bist, Jesu, Du.
|
||||
Wohl mir, ich geh' zu Dir!
|
||||
Bald werd' ich bei Dir sein,
|
||||
Bald mit den Deinen ewiglich
|
||||
Anbeten, loben, preisen Dich,
|
||||
Mich Deiner stets erfreun.","NULL"
|
|
21
tests/resources/worshipassistantsongs/du_herr.json
Normal file
21
tests/resources/worshipassistantsongs/du_herr.json
Normal file
@ -0,0 +1,21 @@
|
||||
{
|
||||
"authors": [
|
||||
"Carl Brockhaus / Johann Georg Bäßler 1806"
|
||||
],
|
||||
"title": "Du, Herr, verläßt mich nicht",
|
||||
"verse_order_list": [],
|
||||
"verses": [
|
||||
[
|
||||
"Du, Herr, verläßt mich nicht.\nAuf Dich mein Herz allein vertraut,\nMein Auge glaubend auf Dich schaut.\nDu bist mein Heil, mein Licht,\nMein Fels, mein sichrer Hort.\nBin ich versucht, gibt's Not und Leid,\nDu bleibst mein Trost, mein Arm im Streit,\nMein Licht am dunklen Ort.\n",
|
||||
"v1"
|
||||
],
|
||||
[
|
||||
"Ich weiß, daß Du mich liebst.\nBist mir in jeder Lage nah',\nWohin ich gehe – Du bist da,\nJa, Du mir alles gibst.\nIch überlaß mich Dir;\nDenn Du, Herr, kennst mich ganz und gar\nUnd führst mich sicher, wunderbar,\nUnd bist selbst alles mir.\n",
|
||||
"v2"
|
||||
],
|
||||
[
|
||||
"In dieser Wüste hier\nFind't nirgend meine Seele Ruh',\nDenn meine Ruh' bist, Jesu, Du.\nWohl mir, ich geh' zu Dir!\nBald werd' ich bei Dir sein,\nBald mit den Deinen ewiglich\nAnbeten, loben, preisen Dich,\nMich Deiner stets erfreun.\n",
|
||||
"v3"
|
||||
]
|
||||
]
|
||||
}
|
30
tests/resources/worshipassistantsongs/would_you_be_free.csv
Normal file
30
tests/resources/worshipassistantsongs/would_you_be_free.csv
Normal file
@ -0,0 +1,30 @@
|
||||
SONGNR,TITLE,AUTHOR,COPYRIGHT,FIRSTLINE,PRIKEY,ALTKEY,TEMPO,FOCUS,THEME,SCRIPTURE,ACTIVE,SONGBOOK,TIMESIG,INTRODUCED,LASTUSED,TIMESUSED,CCLINR,USER1,USER2,USER3,USER4,USER5,ROADMAP,FILELINK1,OVERMAP,FILELINK2,LYRICS,INFO,LYRICS2,Background
|
||||
"7","Would You Be Free","Jones, Lewis E.","Public Domain","Would you be free from your burden of sin?","G","","Moderate","Only To Others","","","N","Y","","1899-12-30","1899-12-30","","","","","","","","1,C,1","","","",".G C G
|
||||
Would you be free from your burden of sin?
|
||||
. D D7 G
|
||||
There's power in the blood, power in the blood
|
||||
. C G
|
||||
Would you o'er evil a victory win?
|
||||
. D D7 G
|
||||
There's wonderful power in the blood
|
||||
|
||||
.G C G
|
||||
There is power, power, wonder working power
|
||||
.D G
|
||||
In the blood of the Lamb
|
||||
. C G
|
||||
There is power, power, wonder working power
|
||||
. D G
|
||||
In the precious blood of the Lamb
|
||||
","","[1]
|
||||
Would you be free from your burden of sin?
|
||||
There's power in the blood, power in the blood
|
||||
Would you o'er evil a victory win?
|
||||
There's wonderful power in the blood
|
||||
|
||||
[C]
|
||||
There is power, power, wonder working power
|
||||
In the blood of the Lamb
|
||||
There is power, power, wonder working power
|
||||
In the precious blood of the Lamb
|
||||
",""
|
|
19
tests/resources/worshipassistantsongs/would_you_be_free.json
Normal file
19
tests/resources/worshipassistantsongs/would_you_be_free.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"authors": [
|
||||
"Jones",
|
||||
"Lewis E"
|
||||
],
|
||||
"title": "Would You Be Free",
|
||||
"verse_order_list": ["v1", "c1", "v1"],
|
||||
"copyright": "Public Domain",
|
||||
"verses": [
|
||||
[
|
||||
"Would you be free from your burden of sin? \nThere's power in the blood, power in the blood \nWould you o'er evil a victory win? \nThere's wonderful power in the blood \n",
|
||||
"v1"
|
||||
],
|
||||
[
|
||||
"There is power, power, wonder working power \nIn the blood of the Lamb \nThere is power, power, wonder working power \nIn the precious blood of the Lamb \n",
|
||||
"c1"
|
||||
]
|
||||
]
|
||||
}
|
@ -50,10 +50,6 @@ TAGS = [
|
||||
['1.9.11', '2039'],
|
||||
['1.9.12', '2063'],
|
||||
['2.0', '2118'],
|
||||
['2.0.1', '?'],
|
||||
['2.0.2', '?'],
|
||||
['2.0.3', '?'],
|
||||
['2.0.4', '?'],
|
||||
['2.1.0', '2119']
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user