This commit is contained in:
Tim Bentley 2011-05-20 11:09:51 +01:00
commit cec32eae0f
3 changed files with 9 additions and 3 deletions

View File

@ -207,6 +207,8 @@ class ThemeXML(object):
""" """
A class to encapsulate the Theme XML. A class to encapsulate the Theme XML.
""" """
FIRST_CAMEL_REGEX = re.compile(u'(.)([A-Z][a-z]+)')
SECOND_CAMEL_REGEX = re.compile(u'([a-z0-9])([A-Z])')
def __init__(self): def __init__(self):
""" """
Initialise the theme object. Initialise the theme object.
@ -581,8 +583,8 @@ class ThemeXML(object):
""" """
Change Camel Case string to python string Change Camel Case string to python string
""" """
sub_name = re.sub(u'(.)([A-Z][a-z]+)', r'\1_\2', name) sub_name = ThemeXML.FIRST_CAMEL_REGEX.sub(r'\1_\2', name)
return re.sub(u'([a-z0-9])([A-Z])', r'\1_\2', sub_name).lower() return ThemeXML.SECOND_CAMEL_REGEX.sub(r'\1_\2', sub_name).lower()
def _build_xml_from_attrs(self): def _build_xml_from_attrs(self):
""" """

View File

@ -65,6 +65,9 @@ class EditCustomForm(QtGui.QDialog, Ui_CustomEditDialog):
QtCore.SIGNAL(u'theme_update_list'), self.loadThemes) QtCore.SIGNAL(u'theme_update_list'), self.loadThemes)
QtCore.QObject.connect(self.slideListView, QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged) QtCore.SIGNAL(u'currentRowChanged(int)'), self.onCurrentRowChanged)
QtCore.QObject.connect(self.slideListView,
QtCore.SIGNAL(u'doubleClicked(QModelIndex)'),
self.onEditButtonPressed)
def loadThemes(self, themelist): def loadThemes(self, themelist):
self.themeComboBox.clear() self.themeComboBox.clear()

View File

@ -233,6 +233,7 @@ class OpenLyrics(object):
IMPLEMENTED_VERSION = u'0.7' IMPLEMENTED_VERSION = u'0.7'
def __init__(self, manager): def __init__(self, manager):
self.manager = manager self.manager = manager
self.chord_regex = re.compile(u'<chord name=".*?"/>')
def song_to_xml(self, song): def song_to_xml(self, song):
""" """
@ -317,7 +318,7 @@ class OpenLyrics(object):
if xml[:5] == u'<?xml': if xml[:5] == u'<?xml':
xml = xml[38:] xml = xml[38:]
# Remove chords from xml. # Remove chords from xml.
xml = re.compile(u'<chord name=".*?"/>').sub(u'', xml) xml = self.chord_regex.sub(u'', xml)
song_xml = objectify.fromstring(xml) song_xml = objectify.fromstring(xml)
if hasattr(song_xml, u'properties'): if hasattr(song_xml, u'properties'):
properties = song_xml.properties properties = song_xml.properties