XML: Cleanups

This commit is contained in:
Jon Tibble 2010-07-03 14:26:29 +01:00
parent 497d1c9dc9
commit 732bf24ef8
4 changed files with 12 additions and 26 deletions

View File

@ -202,15 +202,6 @@ def check_item_selected(list_widget, message):
return False
return True
class ThemeLevel(object):
"""
Provides an enumeration for the level a theme applies to
"""
Global = 1
Service = 2
Song = 3
from eventreceiver import Receiver
from settingsmanager import SettingsManager
from plugin import PluginStatus, Plugin
@ -221,7 +212,7 @@ from serviceitem import ServiceItemType
from serviceitem import ItemCapabilities
from toolbar import OpenLPToolbar
from dockwidget import OpenLPDockWidget
from themexmlhandler import ThemeXML
from theme import ThemeLevel, ThemeXML
from renderer import Renderer
from rendermanager import RenderManager
from mediamanageritem import MediaManagerItem

View File

@ -79,6 +79,14 @@ BLANK_THEME_XML = \
</theme>
'''
class ThemeLevel(object):
"""
Provides an enumeration for the level a theme applies to
"""
Global = 1
Service = 2
Song = 3
class ThemeXML(object):
"""
A class to encapsulate the Theme XML.
@ -313,7 +321,6 @@ class ThemeXML(object):
element.appendChild(value)
background.appendChild(element)
def child_element(self, element, tag, value):
"""
Generic child element creator.
@ -414,4 +421,3 @@ class ThemeXML(object):
if key[0:1] != u'_':
theme_strings.append(u'%30s: %s' % (key, getattr(self, key)))
return u'\n'.join(theme_strings)

View File

@ -34,10 +34,8 @@ from xml.etree.ElementTree import ElementTree, XML
#sys.path.append(os.path.abspath(u'./../../../..'))
#sys.path.append(os.path.abspath(os.path.join(u'.', u'..', u'..')))
log = logging.getLogger(__name__)
class SongException(Exception):
pass
@ -84,7 +82,9 @@ class _OpenSong(object):
"""
Initialize from given xml content
"""
self.from_buffer(xmlContent)
self._set_from_xml(_BLANK_OPENSONG_XML, 'song')
if xmlContent:
self._set_from_xml(xmlContent, 'song')
def _set_from_xml(self, xml, root_tag):
"""
@ -147,16 +147,6 @@ class _OpenSong(object):
result += u'_%s_' % getattr(self, attrib)
return result
def _reset(self):
"""Reset all song attributes"""
self._setFromXml(_BLANK_OPENSONG_XML, 'song')
def from_buffer(self, xmlContent):
"""Initialize from buffer(string) with xml content"""
self._reset()
if xmlContent:
self._setFromXml(xmlContent, 'song')
def get_author_list(self):
"""Convert author field to an authorlist

View File

@ -136,4 +136,3 @@ class LyricsXML(object):
song_output = u'<?xml version="1.0" encoding="UTF-8"?>' + \
u'<song version="1.0">%s</song>' % lyrics_output
return song_output