Keep library classes/methods in lib dirs

This commit is contained in:
Jon Tibble 2010-06-12 13:33:04 +01:00
parent 47d931f4a6
commit 13c646153f
5 changed files with 71 additions and 72 deletions

View File

@ -23,74 +23,6 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class VerseType(object):
"""
VerseType provides an enumeration for the tags that may be associated
with verses in songs.
"""
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
"""
Return a string for a given VerseType
``verse_type``
The type to return a string for
"""
if verse_type == VerseType.Verse:
return translate(u'VerseType', u'Verse')
elif verse_type == VerseType.Chorus:
return translate(u'VerseType', u'Chorus')
elif verse_type == VerseType.Bridge:
return translate(u'VerseType', u'Bridge')
elif verse_type == VerseType.PreChorus:
return translate(u'VerseType', u'Pre-Chorus')
elif verse_type == VerseType.Intro:
return translate(u'VerseType', u'Intro')
elif verse_type == VerseType.Ending:
return translate(u'VerseType', u'Ending')
elif verse_type == VerseType.Other:
return translate(u'VerseType', u'Other')
@staticmethod
def from_string(verse_type):
"""
Return the VerseType for a given string
``verse_type``
The string to return a VerseType for
"""
verse_type = verse_type.lower()
if verse_type == unicode(VerseType.to_string(VerseType.Verse)).lower():
return VerseType.Verse
elif verse_type == \
unicode(VerseType.to_string(VerseType.Chorus)).lower():
return VerseType.Chorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Bridge)).lower():
return VerseType.Bridge
elif verse_type == \
unicode(VerseType.to_string(VerseType.PreChorus)).lower():
return VerseType.PreChorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Intro)).lower():
return VerseType.Intro
elif verse_type == \
unicode(VerseType.to_string(VerseType.Ending)).lower():
return VerseType.Ending
elif verse_type == \
unicode(VerseType.to_string(VerseType.Other)).lower():
return VerseType.Other
from authorsform import AuthorsForm from authorsform import AuthorsForm
from topicsform import TopicsForm from topicsform import TopicsForm
from songbookform import SongBookForm from songbookform import SongBookForm

View File

@ -26,7 +26,7 @@
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.core.lib import translate from openlp.core.lib import translate
from openlp.plugins.songs.forms import VerseType from openlp.plugins.songs.lib import VerseType
class Ui_EditVerseDialog(object): class Ui_EditVerseDialog(object):
def setupUi(self, EditVerseDialog): def setupUi(self, EditVerseDialog):

View File

@ -28,7 +28,7 @@ import logging
from PyQt4 import QtCore, QtGui from PyQt4 import QtCore, QtGui
from openlp.plugins.songs.forms import VerseType from openlp.plugins.songs.lib import VerseType
from editversedialog import Ui_EditVerseDialog from editversedialog import Ui_EditVerseDialog

View File

@ -23,10 +23,77 @@
# Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Temple Place, Suite 330, Boston, MA 02111-1307 USA #
############################################################################### ###############################################################################
from openlp.core.lib import translate
class VerseType(object):
"""
VerseType provides an enumeration for the tags that may be associated
with verses in songs.
"""
Verse = 0
Chorus = 1
Bridge = 2
PreChorus = 3
Intro = 4
Ending = 5
Other = 6
@staticmethod
def to_string(verse_type):
"""
Return a string for a given VerseType
``verse_type``
The type to return a string for
"""
if verse_type == VerseType.Verse:
return translate(u'VerseType', u'Verse')
elif verse_type == VerseType.Chorus:
return translate(u'VerseType', u'Chorus')
elif verse_type == VerseType.Bridge:
return translate(u'VerseType', u'Bridge')
elif verse_type == VerseType.PreChorus:
return translate(u'VerseType', u'Pre-Chorus')
elif verse_type == VerseType.Intro:
return translate(u'VerseType', u'Intro')
elif verse_type == VerseType.Ending:
return translate(u'VerseType', u'Ending')
elif verse_type == VerseType.Other:
return translate(u'VerseType', u'Other')
@staticmethod
def from_string(verse_type):
"""
Return the VerseType for a given string
``verse_type``
The string to return a VerseType for
"""
verse_type = verse_type.lower()
if verse_type == unicode(VerseType.to_string(VerseType.Verse)).lower():
return VerseType.Verse
elif verse_type == \
unicode(VerseType.to_string(VerseType.Chorus)).lower():
return VerseType.Chorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Bridge)).lower():
return VerseType.Bridge
elif verse_type == \
unicode(VerseType.to_string(VerseType.PreChorus)).lower():
return VerseType.PreChorus
elif verse_type == \
unicode(VerseType.to_string(VerseType.Intro)).lower():
return VerseType.Intro
elif verse_type == \
unicode(VerseType.to_string(VerseType.Ending)).lower():
return VerseType.Ending
elif verse_type == \
unicode(VerseType.to_string(VerseType.Other)).lower():
return VerseType.Other
from manager import SongManager from manager import SongManager
from songstab import SongsTab from songstab import SongsTab
from mediaitem import SongMediaItem from mediaitem import SongMediaItem
from sofimport import SofImport from sofimport import SofImport
from oooimport import OooImport from oooimport import OooImport
from songimport import SongImport from songimport import SongImport

View File

@ -28,8 +28,8 @@ import string
from PyQt4 import QtGui from PyQt4 import QtGui
from openlp.core.lib import SongXMLBuilder from openlp.core.lib import SongXMLBuilder
from openlp.plugins.songs.lib import VerseType
from openlp.plugins.songs.lib.models import Song, Author, Topic, Book from openlp.plugins.songs.lib.models import Song, Author, Topic, Book
from openlp.plugins.songs.forms import VerseType
class SongImport(object): class SongImport(object):
""" """