openlp-core team mailing list archive
-
openlp-core team
-
Mailing list archive
-
Message #10807
[Merge] lp:~googol/openlp/trivial into lp:openlp
Andreas Preikschat has proposed merging lp:~googol/openlp/trivial into lp:openlp.
Requested reviews:
OpenLP Core (openlp-core)
For more details, see:
https://code.launchpad.net/~googol/openlp/trivial/+merge/67837
Hello,
- use map instead of list comprehension
- make some instance variables (in connection with re) constants
- removed some blank lines
--
https://code.launchpad.net/~googol/openlp/trivial/+merge/67837
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/trivial into lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py 2011-06-12 16:02:52 +0000
+++ openlp/core/utils/__init__.py 2011-07-13 15:45:49 +0000
@@ -53,6 +53,7 @@
IMAGES_FILTER = None
UNO_CONNECTION_TYPE = u'pipe'
#UNO_CONNECTION_TYPE = u'socket'
+VERSION_SPLITTER = re.compile(r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
class VersionThread(QtCore.QThread):
"""
@@ -61,8 +62,6 @@
"""
def __init__(self, parent):
QtCore.QThread.__init__(self, parent)
- self.version_splitter = re.compile(
- r'([0-9]+).([0-9]+).([0-9]+)(?:-bzr([0-9]+))?')
def run(self):
"""
@@ -73,7 +72,7 @@
version = check_latest_version(app_version)
remote_version = {}
local_version = {}
- match = self.version_splitter.match(version)
+ match = VERSION_SPLITTER.match(version)
if match:
remote_version[u'major'] = int(match.group(1))
remote_version[u'minor'] = int(match.group(2))
@@ -82,7 +81,7 @@
remote_version[u'revision'] = int(match.group(4))
else:
return
- match = self.version_splitter.match(app_version[u'full'])
+ match = VERSION_SPLITTER.match(app_version[u'full'])
if match:
local_version[u'major'] = int(match.group(1))
local_version[u'minor'] = int(match.group(2))
=== modified file 'openlp/plugins/bibles/forms/bibleupgradeform.py'
--- openlp/plugins/bibles/forms/bibleupgradeform.py 2011-06-11 08:41:32 +0000
+++ openlp/plugins/bibles/forms/bibleupgradeform.py 2011-07-13 15:45:49 +0000
@@ -27,8 +27,7 @@
The bible import functions for OpenLP
"""
import logging
-import os.path
-import re
+import os
import shutil
from PyQt4 import QtCore, QtGui
@@ -70,8 +69,7 @@
self.mediaItem = bibleplugin.mediaItem
self.suffix = u'.sqlite'
self.settingsSection = u'bibles'
- self.path = AppLocation.get_section_data_path(
- self.settingsSection)
+ self.path = AppLocation.get_section_data_path(self.settingsSection)
self.files = self.manager.old_bible_databases
self.success = {}
self.newbibles = {}
=== modified file 'openlp/plugins/songs/forms/editverseform.py'
--- openlp/plugins/songs/forms/editverseform.py 2011-06-14 06:18:44 +0000
+++ openlp/plugins/songs/forms/editverseform.py 2011-07-13 15:45:49 +0000
@@ -37,6 +37,8 @@
log = logging.getLogger(__name__)
+VERSE_REGEX = re.compile(r'---\[(.+):\D*(\d*)\D*.*\]---')
+
class EditVerseForm(QtGui.QDialog, Ui_EditVerseDialog):
"""
This is the form that is used to edit the verses of the song.
@@ -60,7 +62,6 @@
QtCore.QObject.connect(self.verseTypeComboBox,
QtCore.SIGNAL(u'currentIndexChanged(int)'),
self.onVerseTypeComboBoxChanged)
- self.verse_regex = re.compile(r'---\[(.+):\D*(\d*)\D*.*\]---')
def contextMenu(self, point):
item = self.serviceManagerList.itemAt(point)
@@ -105,7 +106,7 @@
if position == -1:
return
text = text[:position + 4]
- match = self.verse_regex.match(text)
+ match = VERSE_REGEX.match(text)
if match:
verse_tag = match.group(1)
try:
@@ -136,7 +137,7 @@
if position == -1:
return
text = text[:position + 4]
- match = self.verse_regex.match(text)
+ match = VERSE_REGEX.match(text)
if match:
verse_type = match.group(1)
verse_type_index = VerseType.from_loose_input(verse_type)
=== modified file 'openlp/plugins/songs/lib/xml.py'
--- openlp/plugins/songs/lib/xml.py 2011-06-18 08:54:34 +0000
+++ openlp/plugins/songs/lib/xml.py 2011-07-13 15:45:49 +0000
@@ -73,6 +73,8 @@
log = logging.getLogger(__name__)
+CHORD_REGEX = re.compile(u'<chord name=".*?"/>')
+
class SongXML(object):
"""
This class builds and parses the XML used to describe songs.
@@ -234,7 +236,6 @@
IMPLEMENTED_VERSION = u'0.7'
def __init__(self, manager):
self.manager = manager
- self.chord_regex = re.compile(u'<chord name=".*?"/>')
def song_to_xml(self, song):
"""
@@ -319,7 +320,7 @@
if xml[:5] == u'<?xml':
xml = xml[38:]
# Remove chords from xml.
- xml = self.chord_regex.sub(u'', xml)
+ xml = CHORD_REGEX.sub(u'', xml)
song_xml = objectify.fromstring(xml)
if hasattr(song_xml, u'properties'):
properties = song_xml.properties
=== modified file 'scripts/check_dependencies.py'
--- scripts/check_dependencies.py 2011-07-10 12:00:58 +0000
+++ scripts/check_dependencies.py 2011-07-13 15:45:49 +0000
@@ -74,44 +74,38 @@
('sqlite', ' (SQLite 2 support)'),
('MySQLdb', ' (MySQL support)'),
('psycopg2', ' (PostgreSQL support)'),
- ]
+]
w = sys.stdout.write
-
def check_vers(version, required, text):
if type(version) is str:
version = version.split('.')
- version = [int(x) for x in version]
+ version = map(int, version)
if type(required) is str:
required = required.split('.')
- required = [int(x) for x in required]
- w(' %s >= %s ... ' % (text, '.'.join([str(x) for x in required])))
+ required = map(int, required)
+ w(' %s >= %s ... ' % (text, '.'.join(map(str, required))))
if version >= required:
- w('.'.join([str(x) for x in version]) + os.linesep)
+ w('.'.join(map(str, version)) + os.linesep)
return True
else:
w('FAIL' + os.linesep)
return False
-
def print_vers_fail(required, text):
print(' %s >= %s ... FAIL' % (text, required))
-
def verify_python():
if not check_vers(list(sys.version_info), VERS['Python'], text='Python'):
exit(1)
-
def verify_versions():
print('Verifying version of modules...')
try:
from PyQt4 import QtCore
- check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'],
- 'PyQt4')
- check_vers(QtCore.qVersion(), VERS['Qt4'],
- 'Qt4')
+ check_vers(QtCore.PYQT_VERSION_STR, VERS['PyQt4'], 'PyQt4')
+ check_vers(QtCore.qVersion(), VERS['Qt4'], 'Qt4')
except ImportError:
print_vers_fail(VERS['PyQt4'], 'PyQt4')
print_vers_fail(VERS['Qt4'], 'Qt4')
@@ -126,7 +120,6 @@
except ImportError:
print_vers_fail(VERS['enchant'], 'enchant')
-
def check_module(mod, text='', indent=' '):
space = (30 - len(mod) - len(text)) * ' '
w(indent + '%s%s... ' % (mod, text) + space)
@@ -137,7 +130,6 @@
w('FAIL')
w(os.linesep)
-
def verify_pyenchant():
w('Enchant (spell checker)... ')
try:
@@ -150,14 +142,13 @@
except ImportError:
w('FAIL' + os.linesep)
-
def verify_pyqt():
w('Qt4 image formats... ')
try:
from PyQt4 import QtGui
- read_f = ', '.join([unicode(format).lower() \
+ read_f = ', '.join([unicode(format).lower()
for format in QtGui.QImageReader.supportedImageFormats()])
- write_f= ', '.join([unicode(format).lower() \
+ write_f = ', '.join([unicode(format).lower()
for format in QtGui.QImageWriter.supportedImageFormats()])
w(os.linesep)
print(' read: %s' % read_f)
@@ -165,9 +156,7 @@
except ImportError:
w('FAIL' + os.linesep)
-
def main():
-
verify_python()
print('Checking for modules...')
@@ -187,6 +176,5 @@
verify_pyqt()
verify_pyenchant()
-
if __name__ == u'__main__':
main()
Follow ups