forked from openlp/openlp
merge trunk
This commit is contained in:
commit
0e0dbdbfb9
66
openlp/core/ui/media/vendor/vlc.py
vendored
66
openlp/core/ui/media/vendor/vlc.py
vendored
@ -48,13 +48,13 @@ import sys
|
|||||||
from inspect import getargspec
|
from inspect import getargspec
|
||||||
|
|
||||||
__version__ = "N/A"
|
__version__ = "N/A"
|
||||||
build_date = "Mon Apr 1 23:47:38 2013"
|
build_date = "Tue Jul 2 10:35:53 2013"
|
||||||
|
|
||||||
if sys.version_info[0] > 2:
|
if sys.version_info[0] > 2:
|
||||||
str = str
|
str = str
|
||||||
str = str
|
unicode = str
|
||||||
bytes = bytes
|
bytes = bytes
|
||||||
str = (str, bytes)
|
basestring = (str, bytes)
|
||||||
PYTHON3 = True
|
PYTHON3 = True
|
||||||
def str_to_bytes(s):
|
def str_to_bytes(s):
|
||||||
"""Translate string or bytes to bytes.
|
"""Translate string or bytes to bytes.
|
||||||
@ -73,14 +73,14 @@ if sys.version_info[0] > 2:
|
|||||||
return b
|
return b
|
||||||
else:
|
else:
|
||||||
str = str
|
str = str
|
||||||
str = str
|
unicode = unicode
|
||||||
bytes = str
|
bytes = str
|
||||||
str = str
|
basestring = basestring
|
||||||
PYTHON3 = False
|
PYTHON3 = False
|
||||||
def str_to_bytes(s):
|
def str_to_bytes(s):
|
||||||
"""Translate string or bytes to bytes.
|
"""Translate string or bytes to bytes.
|
||||||
"""
|
"""
|
||||||
if isinstance(s, str):
|
if isinstance(s, unicode):
|
||||||
return s.encode(sys.getfilesystemencoding())
|
return s.encode(sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
return s
|
return s
|
||||||
@ -89,7 +89,7 @@ else:
|
|||||||
"""Translate bytes to unicode string.
|
"""Translate bytes to unicode string.
|
||||||
"""
|
"""
|
||||||
if isinstance(b, str):
|
if isinstance(b, str):
|
||||||
return str(b, sys.getfilesystemencoding())
|
return unicode(b, sys.getfilesystemencoding())
|
||||||
else:
|
else:
|
||||||
return b
|
return b
|
||||||
|
|
||||||
@ -110,7 +110,7 @@ def find_lib():
|
|||||||
p = find_library('libvlc.dll')
|
p = find_library('libvlc.dll')
|
||||||
if p is None:
|
if p is None:
|
||||||
try: # some registry settings
|
try: # some registry settings
|
||||||
import winreg as w # leaner than win32api, win32con
|
import _winreg as w # leaner than win32api, win32con
|
||||||
for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER:
|
for r in w.HKEY_LOCAL_MACHINE, w.HKEY_CURRENT_USER:
|
||||||
try:
|
try:
|
||||||
r = w.OpenKey(r, 'Software\\VideoLAN\\VLC')
|
r = w.OpenKey(r, 'Software\\VideoLAN\\VLC')
|
||||||
@ -168,7 +168,7 @@ class VLCException(Exception):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
_Ints = (int, int)
|
_Ints = (int, long)
|
||||||
except NameError: # no long in Python 3+
|
except NameError: # no long in Python 3+
|
||||||
_Ints = int
|
_Ints = int
|
||||||
_Seqs = (list, tuple)
|
_Seqs = (list, tuple)
|
||||||
@ -327,6 +327,9 @@ class _Enum(ctypes.c_uint):
|
|||||||
n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,))
|
n = self._enum_names_.get(self.value, '') or ('FIXME_(%r)' % (self.value,))
|
||||||
return '.'.join((self.__class__.__name__, n))
|
return '.'.join((self.__class__.__name__, n))
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '.'.join((self.__class__.__module__, self.__str__()))
|
return '.'.join((self.__class__.__module__, self.__str__()))
|
||||||
|
|
||||||
@ -1294,7 +1297,7 @@ class Instance(_Ctype):
|
|||||||
i = args[0]
|
i = args[0]
|
||||||
if isinstance(i, _Ints):
|
if isinstance(i, _Ints):
|
||||||
return _Constructor(cls, i)
|
return _Constructor(cls, i)
|
||||||
elif isinstance(i, str):
|
elif isinstance(i, basestring):
|
||||||
args = i.strip().split()
|
args = i.strip().split()
|
||||||
elif isinstance(i, _Seqs):
|
elif isinstance(i, _Seqs):
|
||||||
args = i
|
args = i
|
||||||
@ -2078,7 +2081,7 @@ class MediaList(_Ctype):
|
|||||||
@param mrl: a media instance or a MRL.
|
@param mrl: a media instance or a MRL.
|
||||||
@return: 0 on success, -1 if the media list is read-only.
|
@return: 0 on success, -1 if the media list is read-only.
|
||||||
"""
|
"""
|
||||||
if isinstance(mrl, str):
|
if isinstance(mrl, basestring):
|
||||||
mrl = (self.get_instance() or get_default_instance()).media_new(mrl)
|
mrl = (self.get_instance() or get_default_instance()).media_new(mrl)
|
||||||
return libvlc_media_list_add_media(self, mrl)
|
return libvlc_media_list_add_media(self, mrl)
|
||||||
|
|
||||||
@ -3351,6 +3354,39 @@ def libvlc_event_type_name(event_type):
|
|||||||
ctypes.c_char_p, ctypes.c_uint)
|
ctypes.c_char_p, ctypes.c_uint)
|
||||||
return f(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
|
||||||
|
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.
|
||||||
|
@param ctx: message context (as passed to the @ref libvlc_log_cb callback).
|
||||||
|
@return: module module name storage (or NULL), file source code file name storage (or NULL), line source code file line number storage (or NULL).
|
||||||
|
@version: LibVLC 2.1.0 or later.
|
||||||
|
'''
|
||||||
|
f = _Cfunctions.get('libvlc_log_get_context', None) or \
|
||||||
|
_Cfunction('libvlc_log_get_context', ((1,), (2,), (2,), (2,),), None,
|
||||||
|
None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint))
|
||||||
|
return f(ctx)
|
||||||
|
|
||||||
|
def libvlc_log_get_object(ctx, id):
|
||||||
|
'''Gets VLC object informations 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}
|
||||||
|
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
|
||||||
|
is used to distinguish for VLM inputs.
|
||||||
|
The returned object ID will be zero if the message is not associated with
|
||||||
|
any VLC object.
|
||||||
|
@param ctx: message context (as passed to the @ref libvlc_log_cb callback).
|
||||||
|
@return: name object name storage (or NULL), header object header (or NULL), line source code file line number storage (or NULL).
|
||||||
|
@version: LibVLC 2.1.0 or later.
|
||||||
|
'''
|
||||||
|
f = _Cfunctions.get('libvlc_log_get_object', None) or \
|
||||||
|
_Cfunction('libvlc_log_get_object', ((1,), (2,), (2,), (1,),), None,
|
||||||
|
None, Log_ptr, ListPOINTER(ctypes.c_char_p), ListPOINTER(ctypes.c_char_p), ctypes.POINTER(ctypes.c_uint))
|
||||||
|
return f(ctx, id)
|
||||||
|
|
||||||
def libvlc_log_unset(p_instance):
|
def libvlc_log_unset(p_instance):
|
||||||
'''Unsets the logging callback for a LibVLC instance. This is rarely needed:
|
'''Unsets the logging callback for a LibVLC instance. This is rarely needed:
|
||||||
the callback is implicitly unset when the instance is destroyed.
|
the callback is implicitly unset when the instance is destroyed.
|
||||||
@ -5827,7 +5863,7 @@ def libvlc_vlm_get_event_manager(p_instance):
|
|||||||
# libvlc_printerr
|
# libvlc_printerr
|
||||||
# libvlc_set_exit_handler
|
# libvlc_set_exit_handler
|
||||||
|
|
||||||
# 15 function(s) not wrapped as methods:
|
# 17 function(s) not wrapped as methods:
|
||||||
# libvlc_audio_output_device_list_release
|
# libvlc_audio_output_device_list_release
|
||||||
# libvlc_audio_output_list_release
|
# libvlc_audio_output_list_release
|
||||||
# libvlc_clearerr
|
# libvlc_clearerr
|
||||||
@ -5838,6 +5874,8 @@ def libvlc_vlm_get_event_manager(p_instance):
|
|||||||
# libvlc_get_changeset
|
# libvlc_get_changeset
|
||||||
# libvlc_get_compiler
|
# libvlc_get_compiler
|
||||||
# libvlc_get_version
|
# libvlc_get_version
|
||||||
|
# libvlc_log_get_context
|
||||||
|
# libvlc_log_get_object
|
||||||
# libvlc_media_tracks_release
|
# libvlc_media_tracks_release
|
||||||
# libvlc_module_description_list_release
|
# libvlc_module_description_list_release
|
||||||
# libvlc_new
|
# libvlc_new
|
||||||
@ -5910,9 +5948,9 @@ def debug_callback(event, *args, **kwds):
|
|||||||
'''
|
'''
|
||||||
l = ['event %s' % (event.type,)]
|
l = ['event %s' % (event.type,)]
|
||||||
if args:
|
if args:
|
||||||
l.extend(list(map(str, args)))
|
l.extend(map(str, args))
|
||||||
if kwds:
|
if kwds:
|
||||||
l.extend(sorted('%s=%s' % t for t in list(kwds.items())))
|
l.extend(sorted('%s=%s' % t for t in kwds.items()))
|
||||||
print('Debug callback (%s)' % ', '.join(l))
|
print('Debug callback (%s)' % ', '.join(l))
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
@ -191,7 +191,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
:param testament: *Defaults to 1.* The testament_reference_id from
|
:param testament: *Defaults to 1.* The testament_reference_id from
|
||||||
bibles_resources.sqlite of the testament this book belongs to.
|
bibles_resources.sqlite of the testament this book belongs to.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.create_book("%s", "%s")', name, bk_ref_id)
|
log.debug('BibleDB.create_book("%s", "%s")' % (name, bk_ref_id))
|
||||||
book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament)
|
book = Book.populate(name=name, book_reference_id=bk_ref_id, testament_reference_id=testament)
|
||||||
self.save_object(book)
|
self.save_object(book)
|
||||||
return book
|
return book
|
||||||
@ -202,7 +202,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
|
|
||||||
:param book: The book object
|
:param book: The book object
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.update_book("%s")', book.name)
|
log.debug('BibleDB.update_book("%s")' % book.name)
|
||||||
return self.save_object(book)
|
return self.save_object(book)
|
||||||
|
|
||||||
def delete_book(self, db_book):
|
def delete_book(self, db_book):
|
||||||
@ -211,7 +211,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
|
|
||||||
:param db_book: The book object.
|
:param db_book: The book object.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.delete_book("%s")', db_book.name)
|
log.debug('BibleDB.delete_book("%s")' % db_book.name)
|
||||||
if self.delete_object(Book, db_book.id):
|
if self.delete_object(Book, db_book.id):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@ -225,7 +225,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
:param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the
|
:param text_list: A dict of the verses to be inserted. The key is the verse number, and the value is the
|
||||||
verse text.
|
verse text.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDBcreate_chapter("%s", "%s")', book_id, chapter)
|
log.debug('BibleDBcreate_chapter("%s", "%s")' % (book_id, chapter))
|
||||||
# Text list has book and chapter as first two elements of the array.
|
# Text list has book and chapter as first two elements of the array.
|
||||||
for verse_number, verse_text in text_list.items():
|
for verse_number, verse_text in text_list.items():
|
||||||
verse = Verse.populate(
|
verse = Verse.populate(
|
||||||
@ -267,7 +267,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
"""
|
"""
|
||||||
if not isinstance(value, str):
|
if not isinstance(value, str):
|
||||||
value = str(value)
|
value = str(value)
|
||||||
log.debug('BibleDB.save_meta("%s/%s")', key, value)
|
log.debug('BibleDB.save_meta("%s/%s")' % (key, value))
|
||||||
meta = self.get_object(BibleMeta, key)
|
meta = self.get_object(BibleMeta, key)
|
||||||
if meta:
|
if meta:
|
||||||
meta.value = value
|
meta.value = value
|
||||||
@ -281,7 +281,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
|
|
||||||
:param book: The name of the book to return.
|
:param book: The name of the book to return.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.get_book("%s")', book)
|
log.debug('BibleDB.get_book("%s")' % book)
|
||||||
return self.get_object_filtered(Book, Book.name.like(book + '%'))
|
return self.get_object_filtered(Book, Book.name.like(book + '%'))
|
||||||
|
|
||||||
def get_books(self):
|
def get_books(self):
|
||||||
@ -292,17 +292,17 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
log.debug('BibleDB.get_books()')
|
log.debug('BibleDB.get_books()')
|
||||||
return self.get_all_objects(Book, order_by_ref=Book.id)
|
return self.get_all_objects(Book, order_by_ref=Book.id)
|
||||||
|
|
||||||
def get_book_by_book_ref_id(self, id):
|
def get_book_by_book_ref_id(self, ref_id):
|
||||||
"""
|
"""
|
||||||
Return a book object from the database.
|
Return a book object from the database.
|
||||||
|
|
||||||
:param id: The reference id of the book to return.
|
:param ref_id: The reference id of the book to return.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.get_book_by_book_ref_id("%s")', id)
|
log.debug('BibleDB.get_book_by_book_ref_id("%s")' % ref_id)
|
||||||
return self.get_object_filtered(Book, Book.book_reference_id.like(id))
|
return self.get_object_filtered(Book, Book.book_reference_id.like(ref_id))
|
||||||
|
|
||||||
def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
|
def get_book_ref_id_by_name(self, book, maxbooks, language_id=None):
|
||||||
log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")', book, language_id)
|
log.debug('BibleDB.get_book_ref_id_by_name:("%s", "%s")' % (book, language_id))
|
||||||
book_id = None
|
book_id = None
|
||||||
if BiblesResourcesDB.get_book(book, True):
|
if BiblesResourcesDB.get_book(book, True):
|
||||||
book_temp = BiblesResourcesDB.get_book(book, True)
|
book_temp = BiblesResourcesDB.get_book(book, True)
|
||||||
@ -328,7 +328,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
:param book: The name of the book, according to the selected language.
|
:param book: The name of the book, according to the selected language.
|
||||||
:param language_selection: The language selection the user has chosen in the settings section of the Bible.
|
:param language_selection: The language selection the user has chosen in the settings section of the Bible.
|
||||||
"""
|
"""
|
||||||
log.debug('get_book_ref_id_by_localised_name("%s", "%s")', book, language_selection)
|
log.debug('get_book_ref_id_by_localised_name("%s", "%s")' % (book, language_selection))
|
||||||
from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings
|
from openlp.plugins.bibles.lib import LanguageSelection, BibleStrings
|
||||||
book_names = BibleStrings().BookNames
|
book_names = BibleStrings().BookNames
|
||||||
# escape reserved characters
|
# escape reserved characters
|
||||||
@ -376,14 +376,14 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
[(u'35', 1, 1, 1), (u'35', 2, 2, 3)]
|
[(u'35', 1, 1, 1), (u'35', 2, 2, 3)]
|
||||||
:param show_error:
|
:param show_error:
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.get_verses("%s")', reference_list)
|
log.debug('BibleDB.get_verses("%s")' % reference_list)
|
||||||
verse_list = []
|
verse_list = []
|
||||||
book_error = False
|
book_error = False
|
||||||
for book_id, chapter, start_verse, end_verse in reference_list:
|
for book_id, chapter, start_verse, end_verse in reference_list:
|
||||||
db_book = self.get_book_by_book_ref_id(book_id)
|
db_book = self.get_book_by_book_ref_id(book_id)
|
||||||
if db_book:
|
if db_book:
|
||||||
book_id = db_book.book_reference_id
|
book_id = db_book.book_reference_id
|
||||||
log.debug('Book name corrected to "%s"', db_book.name)
|
log.debug('Book name corrected to "%s"' % db_book.name)
|
||||||
if end_verse == -1:
|
if end_verse == -1:
|
||||||
end_verse = self.get_verse_count(book_id, chapter)
|
end_verse = self.get_verse_count(book_id, chapter)
|
||||||
verses = self.session.query(Verse) \
|
verses = self.session.query(Verse) \
|
||||||
@ -395,7 +395,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
.all()
|
.all()
|
||||||
verse_list.extend(verses)
|
verse_list.extend(verses)
|
||||||
else:
|
else:
|
||||||
log.debug('OpenLP failed to find book with id "%s"', book_id)
|
log.debug('OpenLP failed to find book with id "%s"' % book_id)
|
||||||
book_error = True
|
book_error = True
|
||||||
if book_error and show_error:
|
if book_error and show_error:
|
||||||
critical_error_message_box(
|
critical_error_message_box(
|
||||||
@ -414,7 +414,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
contains spaces, it will split apart and AND'd on the list of
|
contains spaces, it will split apart and AND'd on the list of
|
||||||
values.
|
values.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.verse_search("%s")', text)
|
log.debug('BibleDB.verse_search("%s")' % text)
|
||||||
verses = self.session.query(Verse)
|
verses = self.session.query(Verse)
|
||||||
if text.find(',') > -1:
|
if text.find(',') > -1:
|
||||||
keywords = ['%%%s%%' % keyword.strip() for keyword in text.split(',')]
|
keywords = ['%%%s%%' % keyword.strip() for keyword in text.split(',')]
|
||||||
@ -433,7 +433,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
|
|
||||||
:param book: The book object to get the chapter count for.
|
:param book: The book object to get the chapter count for.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.get_chapter_count("%s")', book.name)
|
log.debug('BibleDB.get_chapter_count("%s")' % book.name)
|
||||||
count = self.session.query(func.max(Verse.chapter)).join(Book).filter(
|
count = self.session.query(func.max(Verse.chapter)).join(Book).filter(
|
||||||
Book.book_reference_id == book.book_reference_id).scalar()
|
Book.book_reference_id == book.book_reference_id).scalar()
|
||||||
if not count:
|
if not count:
|
||||||
@ -447,7 +447,7 @@ class BibleDB(QtCore.QObject, Manager, RegistryProperties):
|
|||||||
:param book_ref_id: The book reference id.
|
:param book_ref_id: The book reference id.
|
||||||
:param chapter: The chapter to get the verse count for.
|
:param chapter: The chapter to get the verse count for.
|
||||||
"""
|
"""
|
||||||
log.debug('BibleDB.get_verse_count("%s", "%s")', book_ref_id, chapter)
|
log.debug('BibleDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter))
|
||||||
count = self.session.query(func.max(Verse.verse)).join(Book) \
|
count = self.session.query(func.max(Verse.verse)).join(Book) \
|
||||||
.filter(Book.book_reference_id == book_ref_id) \
|
.filter(Book.book_reference_id == book_ref_id) \
|
||||||
.filter(Verse.chapter == chapter) \
|
.filter(Verse.chapter == chapter) \
|
||||||
@ -563,7 +563,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
:param name: The name or abbreviation of the book.
|
:param name: The name or abbreviation of the book.
|
||||||
:param lower: True if the comparison should be only lowercase
|
:param lower: True if the comparison should be only lowercase
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_book("%s")', name)
|
log.debug('BiblesResourcesDB.get_book("%s")' % name)
|
||||||
if not isinstance(name, str):
|
if not isinstance(name, str):
|
||||||
name = str(name)
|
name = str(name)
|
||||||
if lower:
|
if lower:
|
||||||
@ -592,7 +592,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
|
|
||||||
:param string: The string to search for in the book names or abbreviations.
|
:param string: The string to search for in the book names or abbreviations.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_book_like("%s")', string)
|
log.debug('BiblesResourcesDB.get_book_like("%s")' % string)
|
||||||
if not isinstance(string, str):
|
if not isinstance(string, str):
|
||||||
name = str(string)
|
name = str(string)
|
||||||
books = BiblesResourcesDB.run_sql(
|
books = BiblesResourcesDB.run_sql(
|
||||||
@ -611,17 +611,17 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_book_by_id(id):
|
def get_book_by_id(book_id):
|
||||||
"""
|
"""
|
||||||
Return a book by id.
|
Return a book by id.
|
||||||
|
|
||||||
:param id: The id of the book.
|
:param book_id: The id of the book.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_book_by_id("%s")', id)
|
log.debug('BiblesResourcesDB.get_book_by_id("%s")' % book_id)
|
||||||
if not isinstance(id, int):
|
if not isinstance(book_id, int):
|
||||||
id = int(id)
|
book_id = int(book_id)
|
||||||
books = BiblesResourcesDB.run_sql(
|
books = BiblesResourcesDB.run_sql(
|
||||||
'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (id, ))
|
'SELECT id, testament_id, name, abbreviation, chapters FROM book_reference WHERE id = ?', (book_id, ))
|
||||||
if books:
|
if books:
|
||||||
return {
|
return {
|
||||||
'id': books[0][0],
|
'id': books[0][0],
|
||||||
@ -641,7 +641,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
:param book_ref_id: The id of a book.
|
:param book_ref_id: The id of a book.
|
||||||
:param chapter: The chapter number.
|
:param chapter: The chapter number.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_chapter("%s", "%s")', book_ref_id, chapter)
|
log.debug('BiblesResourcesDB.get_chapter("%s", "%s")' % (book_ref_id, chapter))
|
||||||
if not isinstance(chapter, int):
|
if not isinstance(chapter, int):
|
||||||
chapter = int(chapter)
|
chapter = int(chapter)
|
||||||
chapters = BiblesResourcesDB.run_sql(
|
chapters = BiblesResourcesDB.run_sql(
|
||||||
@ -664,7 +664,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
|
|
||||||
:param book_ref_id: The id of the book.
|
:param book_ref_id: The id of the book.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_chapter_count("%s")', book_ref_id)
|
log.debug('BiblesResourcesDB.get_chapter_count("%s")' % book_ref_id)
|
||||||
details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
details = BiblesResourcesDB.get_book_by_id(book_ref_id)
|
||||||
if details:
|
if details:
|
||||||
return details['chapters']
|
return details['chapters']
|
||||||
@ -678,7 +678,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
:param book_ref_id: The id of the book.
|
:param book_ref_id: The id of the book.
|
||||||
:param chapter: The number of the chapter.
|
:param chapter: The number of the chapter.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")', book_ref_id, chapter)
|
log.debug('BiblesResourcesDB.get_verse_count("%s", "%s")' % (book_ref_id, chapter))
|
||||||
details = BiblesResourcesDB.get_chapter(book_ref_id, chapter)
|
details = BiblesResourcesDB.get_chapter(book_ref_id, chapter)
|
||||||
if details:
|
if details:
|
||||||
return details['verse_count']
|
return details['verse_count']
|
||||||
@ -691,7 +691,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
|
|
||||||
:param source: The name or abbreviation of the book.
|
:param source: The name or abbreviation of the book.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_download_source("%s")', source)
|
log.debug('BiblesResourcesDB.get_download_source("%s")' % source)
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
source = str(source)
|
source = str(source)
|
||||||
source = source.title()
|
source = source.title()
|
||||||
@ -712,7 +712,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
|
|
||||||
:param source: The source of the web_bible.
|
:param source: The source of the web_bible.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_webbibles("%s")', source)
|
log.debug('BiblesResourcesDB.get_webbibles("%s")' % source)
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
source = str(source)
|
source = str(source)
|
||||||
source = BiblesResourcesDB.get_download_source(source)
|
source = BiblesResourcesDB.get_download_source(source)
|
||||||
@ -737,7 +737,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
:param abbreviation: The abbreviation of the web_bible.
|
:param abbreviation: The abbreviation of the web_bible.
|
||||||
:param source: The source of the web_bible.
|
:param source: The source of the web_bible.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")', abbreviation, source)
|
log.debug('BiblesResourcesDB.get_webbibles("%s", "%s")' % (abbreviation, source))
|
||||||
if not isinstance(abbreviation, str):
|
if not isinstance(abbreviation, str):
|
||||||
abbreviation = str(abbreviation)
|
abbreviation = str(abbreviation)
|
||||||
if not isinstance(source, str):
|
if not isinstance(source, str):
|
||||||
@ -765,7 +765,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
:param name: The name to search the id.
|
:param name: The name to search the id.
|
||||||
:param language_id: The language_id for which language should be searched
|
:param language_id: The language_id for which language should be searched
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")', name, language_id)
|
log.debug('BiblesResourcesDB.get_alternative_book_name("%s", "%s")' % (name, language_id))
|
||||||
if language_id:
|
if language_id:
|
||||||
books = BiblesResourcesDB.run_sql(
|
books = BiblesResourcesDB.run_sql(
|
||||||
'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ? ORDER BY id',
|
'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ? ORDER BY id',
|
||||||
@ -784,7 +784,7 @@ class BiblesResourcesDB(QtCore.QObject, Manager):
|
|||||||
|
|
||||||
:param name: The name or abbreviation of the language.
|
:param name: The name or abbreviation of the language.
|
||||||
"""
|
"""
|
||||||
log.debug('BiblesResourcesDB.get_language("%s")', name)
|
log.debug('BiblesResourcesDB.get_language("%s")' % name)
|
||||||
if not isinstance(name, str):
|
if not isinstance(name, str):
|
||||||
name = str(name)
|
name = str(name)
|
||||||
language = BiblesResourcesDB.run_sql(
|
language = BiblesResourcesDB.run_sql(
|
||||||
@ -880,7 +880,7 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
|||||||
:param name: The name to search the id.
|
:param name: The name to search the id.
|
||||||
:param language_id: The language_id for which language should be searched
|
:param language_id: The language_id for which language should be searched
|
||||||
"""
|
"""
|
||||||
log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")', name, language_id)
|
log.debug('AlternativeBookNamesDB.get_book_reference_id("%s", "%s")' % (name, language_id))
|
||||||
if language_id:
|
if language_id:
|
||||||
books = AlternativeBookNamesDB.run_sql(
|
books = AlternativeBookNamesDB.run_sql(
|
||||||
'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ?', (language_id, ))
|
'SELECT book_reference_id, name FROM alternative_book_names WHERE language_id = ?', (language_id, ))
|
||||||
@ -901,8 +901,8 @@ class AlternativeBookNamesDB(QtCore.QObject, Manager):
|
|||||||
:param book_reference_id: The book_reference_id of the book.
|
:param book_reference_id: The book_reference_id of the book.
|
||||||
:param language_id: The language to which the alternative book name belong.
|
:param language_id: The language to which the alternative book name belong.
|
||||||
"""
|
"""
|
||||||
log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")',
|
log.debug('AlternativeBookNamesDB.create_alternative_book_name("%s", "%s", "%s")' %
|
||||||
name, book_reference_id, language_id)
|
(name, book_reference_id, language_id))
|
||||||
return AlternativeBookNamesDB.run_sql(
|
return AlternativeBookNamesDB.run_sql(
|
||||||
'INSERT INTO alternative_book_names(book_reference_id, language_id, name) '
|
'INSERT INTO alternative_book_names(book_reference_id, language_id, name) '
|
||||||
'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True)
|
'VALUES (?, ?, ?)', (book_reference_id, language_id, name), True)
|
||||||
|
@ -81,3 +81,20 @@ class TestUi(TestCase):
|
|||||||
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
self.assertIsInstance(btnbox, QtGui.QDialogButtonBox)
|
||||||
self.assertEqual(1, len(btnbox.buttons()))
|
self.assertEqual(1, len(btnbox.buttons()))
|
||||||
self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
self.assertEqual(QtGui.QDialogButtonBox.HelpRole, btnbox.buttonRole(btnbox.buttons()[0]))
|
||||||
|
|
||||||
|
def test_create_valign_selection_widgets(self):
|
||||||
|
"""
|
||||||
|
Test creating a combo box for valign selection
|
||||||
|
"""
|
||||||
|
# GIVEN: A dialog
|
||||||
|
dialog = QtGui.QDialog()
|
||||||
|
|
||||||
|
# WHEN: We create the widgets
|
||||||
|
label, combo = create_valign_selection_widgets(dialog)
|
||||||
|
|
||||||
|
# THEN: We should get a label and a combobox.
|
||||||
|
self.assertEqual(translate('OpenLP.Ui', '&Vertical Align:'), label.text())
|
||||||
|
self.assertIsInstance(combo, QtGui.QComboBox)
|
||||||
|
self.assertEqual(combo, label.buddy())
|
||||||
|
for text in [UiStrings().Top, UiStrings().Middle, UiStrings().Bottom]:
|
||||||
|
self.assertTrue(combo.findText(text) >= 0)
|
||||||
|
60
tests/interfaces/openlp_core_ui/test_splashscreen.py
Normal file
60
tests/interfaces/openlp_core_ui/test_splashscreen.py
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
# -*- 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 #
|
||||||
|
###############################################################################
|
||||||
|
"""
|
||||||
|
Test the openlp.core.ui.splashscreen class.
|
||||||
|
"""
|
||||||
|
from unittest import TestCase
|
||||||
|
|
||||||
|
from PyQt4 import QtGui
|
||||||
|
|
||||||
|
from openlp.core.ui import SplashScreen
|
||||||
|
from tests.helpers.testmixin import TestMixin
|
||||||
|
|
||||||
|
|
||||||
|
class TestSplashScreen(TestCase, TestMixin):
|
||||||
|
def setUp(self):
|
||||||
|
self.get_application()
|
||||||
|
self.main_window = QtGui.QMainWindow()
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
"""
|
||||||
|
Delete all the C++ objects at the end so that we don't have a segfault
|
||||||
|
"""
|
||||||
|
del self.app
|
||||||
|
del self.main_window
|
||||||
|
|
||||||
|
def setupUi_test(self):
|
||||||
|
"""
|
||||||
|
Test if the setupUi method....
|
||||||
|
"""
|
||||||
|
# GIVEN: A splash screen instance.
|
||||||
|
splash = SplashScreen()
|
||||||
|
|
||||||
|
# THEN: Check if the splash has a setupUi method.
|
||||||
|
assert hasattr(splash, 'setupUi'), 'The Splash Screen should have a setupUi() method.'
|
Loading…
Reference in New Issue
Block a user