← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~googol/openlp/python3-bzrlib into lp:openlp

 

Andreas Preikschat has proposed merging lp:~googol/openlp/python3-bzrlib into lp:openlp.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~googol/openlp/python3-bzrlib/+merge/159021

Hello,

- Removed some code not compatible with python 3
-- 
https://code.launchpad.net/~googol/openlp/python3-bzrlib/+merge/159021
Your team OpenLP Core is requested to review the proposed merge of lp:~googol/openlp/python3-bzrlib into lp:openlp.
=== modified file 'openlp/core/utils/__init__.py'
--- openlp/core/utils/__init__.py	2013-04-05 17:41:01 +0000
+++ openlp/core/utils/__init__.py	2013-04-15 21:22:28 +0000
@@ -102,45 +102,24 @@
         return APPLICATION_VERSION
     if u'--dev-version' in sys.argv or u'-d' in sys.argv:
         # If we're running the dev version, let's use bzr to get the version.
-        try:
-            # If bzrlib is available, use it.
-            from bzrlib.branch import Branch
-            b = Branch.open_containing('.')[0]
-            b.lock_read()
-            try:
-                # Get the branch's latest revision number.
-                revno = b.revno()
-                # Convert said revision number into a bzr revision id.
-                revision_id = b.dotted_revno_to_revision_id((revno,))
-                # Get a dict of tags, with the revision id as the key.
-                tags = b.tags.get_reverse_tag_dict()
-                # Check if the latest
-                if revision_id in tags:
-                    full_version = u'%s' % tags[revision_id][0]
-                else:
-                    full_version = '%s-bzr%s' % (sorted(b.tags.get_tag_dict().keys())[-1], revno)
-            finally:
-                b.unlock()
-        except:
-            # Otherwise run the command line bzr client.
-            bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
-            output, error = bzr.communicate()
-            code = bzr.wait()
-            if code != 0:
-                raise Exception(u'Error running bzr tags')
-            lines = output.splitlines()
-            if not lines:
-                tag = u'0.0.0'
-                revision = u'0'
-            else:
-                tag, revision = lines[-1].split()
-            bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE)
-            output, error = bzr.communicate()
-            code = bzr.wait()
-            if code != 0:
-                raise Exception(u'Error running bzr log')
-            latest = output.split(u':')[0]
-            full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest)
+        bzr = Popen((u'bzr', u'tags', u'--sort', u'time'), stdout=PIPE)
+        output, error = bzr.communicate()
+        code = bzr.wait()
+        if code != 0:
+            raise Exception(u'Error running bzr tags')
+        lines = output.splitlines()
+        if not lines:
+            tag = u'0.0.0'
+            revision = u'0'
+        else:
+            tag, revision = lines[-1].split()
+        bzr = Popen((u'bzr', u'log', u'--line', u'-r', u'-1'), stdout=PIPE)
+        output, error = bzr.communicate()
+        code = bzr.wait()
+        if code != 0:
+            raise Exception(u'Error running bzr log')
+        latest = output.split(u':')[0]
+        full_version = latest == revision and tag or u'%s-bzr%s' % (tag, latest)
     else:
         # We're not running the development version, let's use the file.
         filepath = AppLocation.get_directory(AppLocation.VersionDir)

=== removed file 'openlp/plugins/bibles/lib/openlp1.py'
--- openlp/plugins/bibles/lib/openlp1.py	2013-03-07 08:05:43 +0000
+++ openlp/plugins/bibles/lib/openlp1.py	1970-01-01 00:00:00 +0000
@@ -1,113 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection                                      #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman                                        #
-# Portions copyright (c) 2008-2013 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                          #
-###############################################################################
-
-import logging
-import sqlite
-import sys
-
-from openlp.core.ui.wizard import WizardStrings
-from openlp.plugins.bibles.lib.db import BibleDB, BiblesResourcesDB
-
-log = logging.getLogger(__name__)
-
-class OpenLP1Bible(BibleDB):
-    """
-    This class provides the OpenLPv1 bible importer.
-    """
-    def __init__(self, parent, **kwargs):
-        """
-        Constructor.
-        """
-        log.debug(self.__class__.__name__)
-        BibleDB.__init__(self, parent, **kwargs)
-        self.filename = kwargs[u'filename']
-
-    def do_import(self, bible_name=None):
-        """
-        Imports an openlp.org v1 bible.
-        """
-        connection = None
-        cursor = None
-        try:
-            connection = sqlite.connect(self.filename.encode(sys.getfilesystemencoding()))
-            cursor = connection.cursor()
-        except sqlite.DatabaseError:
-            log.exception(u'File "%s" is encrypted or not a sqlite database, '
-                'therefore not an openlp.org 1.x database either' % self.filename)
-            # Please add an user error here!
-            # This file is not an openlp.org 1.x bible database.
-            return False
-        #Create the bible language
-        language_id = self.get_language(bible_name)
-        if not language_id:
-            log.exception(u'Importing books from "%s" failed' % self.filename)
-            return False
-        # Create all books.
-        try:
-            cursor.execute(u'SELECT id, testament_id, name, abbreviation FROM book')
-        except sqlite.DatabaseError as error:
-            log.exception(u'DatabaseError: %s' % error)
-            # Please add an user error here!
-            # This file is not an openlp.org 1.x bible database.
-            return False
-        books = cursor.fetchall()
-        self.wizard.progress_bar.setMaximum(len(books) + 1)
-        for book in books:
-            if self.stop_import_flag:
-                connection.close()
-                return False
-            book_id = int(book[0])
-            testament_id = int(book[1])
-            name = unicode(book[2], u'cp1252')
-            abbreviation = unicode(book[3], u'cp1252')
-            book_ref_id = self.get_book_ref_id_by_name(name, len(books),
-                language_id)
-            if not book_ref_id:
-                log.exception(u'Importing books from "%s" failed' % self.filename)
-                return False
-            book_details = BiblesResourcesDB.get_book_by_id(book_ref_id)
-            db_book = self.create_book(name, book_ref_id, book_details[u'testament_id'])
-            # Update the progess bar.
-            self.wizard.increment_progress_bar(WizardStrings.ImportingType % name)
-            # Import the verses for this book.
-            cursor.execute(u'SELECT chapter, verse, text || \'\' AS text FROM '
-                'verse WHERE book_id=%s' % book_id)
-            verses = cursor.fetchall()
-            for verse in verses:
-                if self.stop_import_flag:
-                    connection.close()
-                    return False
-                chapter = int(verse[0])
-                verse_number = int(verse[1])
-                text = unicode(verse[2], u'cp1252')
-                self.create_verse(db_book.id, chapter, verse_number, text)
-                self.application.process_events()
-            self.session.commit()
-        connection.close()
-        return True

=== removed file 'openlp/plugins/songs/lib/olp1import.py'
--- openlp/plugins/songs/lib/olp1import.py	2013-03-07 08:05:43 +0000
+++ openlp/plugins/songs/lib/olp1import.py	1970-01-01 00:00:00 +0000
@@ -1,227 +0,0 @@
-# -*- coding: utf-8 -*-
-# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
-
-###############################################################################
-# OpenLP - Open Source Lyrics Projection                                      #
-# --------------------------------------------------------------------------- #
-# Copyright (c) 2008-2013 Raoul Snyman                                        #
-# Portions copyright (c) 2008-2013 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                          #
-###############################################################################
-"""
-The :mod:`olp1import` module provides the functionality for importing
-openlp.org 1.x song databases into the current installation database.
-"""
-
-import logging
-from chardet.universaldetector import UniversalDetector
-import sqlite
-import sys
-import os
-
-from openlp.core.lib import Registry, translate
-from openlp.plugins.songs.lib import retrieve_windows_encoding
-from songimport import SongImport
-
-log = logging.getLogger(__name__)
-
-class OpenLP1SongImport(SongImport):
-    """
-    The :class:`OpenLP1SongImport` class provides OpenLP with the ability to
-    import song databases from installations of openlp.org 1.x.
-    """
-    lastEncoding = u'windows-1252'
-
-    def __init__(self, manager, **kwargs):
-        """
-        Initialise the import.
-
-        ``manager``
-            The song manager for the running OpenLP installation.
-
-        ``filename``
-            The database providing the data to import.
-        """
-        SongImport.__init__(self, manager, **kwargs)
-
-    def doImport(self):
-        """
-        Run the import for an openlp.org 1.x song database.
-        """
-        if not self.import_source.endswith(u'.olp'):
-            self.logError(self.import_source,
-                translate('SongsPlugin.OpenLP1SongImport', 'Not a valid openlp.org 1.x song database.'))
-            return
-        encoding = self.getEncoding()
-        if not encoding:
-            return
-        # Connect to the database.
-        connection = sqlite.connect(self.import_source, mode=0444, encoding=(encoding, 'replace'))
-        cursor = connection.cursor()
-        # Determine if the db supports linking audio to songs.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'tracks\'')
-        db_has_tracks = len(cursor.fetchall()) > 0
-        # Determine if the db contains theme information.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'settings\'')
-        db_has_themes = len(cursor.fetchall()) > 0
-        # "cache" our list of authors.
-        cursor.execute(u'-- types int, unicode')
-        cursor.execute(u'SELECT authorid, authorname FROM authors')
-        authors = cursor.fetchall()
-        if db_has_tracks:
-            # "cache" our list of tracks.
-            cursor.execute(u'-- types int, unicode')
-            cursor.execute(u'SELECT trackid, fulltrackname FROM tracks')
-            tracks = cursor.fetchall()
-        if db_has_themes:
-            # "cache" our list of themes.
-            themes = {}
-            cursor.execute(u'-- types int, unicode')
-            cursor.execute(u'SELECT settingsid, settingsname FROM settings')
-            for theme_id, theme_name in cursor.fetchall():
-                if theme_name in self.theme_manager.get_themes():
-                    themes[theme_id] = theme_name
-        # Import the songs.
-        cursor.execute(u'-- types int, unicode, unicode, unicode')
-        cursor.execute(u'SELECT songid, songtitle, lyrics || \'\' AS ' \
-                u'lyrics, copyrightinfo FROM songs')
-        songs = cursor.fetchall()
-        self.import_wizard.progress_bar.setMaximum(len(songs))
-        for song in songs:
-            self.setDefaults()
-            if self.stop_import_flag:
-                break
-            song_id = song[0]
-            self.title = song[1]
-            lyrics = song[2].replace(u'\r\n', u'\n')
-            self.addCopyright(song[3])
-            if db_has_themes:
-                cursor.execute(u'-- types int')
-                cursor.execute(
-                    u'SELECT settingsid FROM songs WHERE songid = %s' % song_id)
-                theme_id = cursor.fetchone()[0]
-                self.themeName = themes.get(theme_id, u'')
-            verses = lyrics.split(u'\n\n')
-            for verse in verses:
-                if verse.strip():
-                    self.addVerse(verse.strip())
-            cursor.execute(u'-- types int')
-            cursor.execute(u'SELECT authorid FROM songauthors '
-                u'WHERE songid = %s' % song_id)
-            author_ids = cursor.fetchall()
-            for author_id in author_ids:
-                if self.stop_import_flag:
-                    break
-                for author in authors:
-                    if author[0] == author_id[0]:
-                        self.parse_author(author[1])
-                        break
-            if self.stop_import_flag:
-                break
-            if db_has_tracks:
-                cursor.execute(u'-- types int, int')
-                cursor.execute(u'SELECT trackid, listindex '
-                    u'FROM songtracks '
-                    u'WHERE songid = %s ORDER BY listindex' % song_id)
-                track_ids = cursor.fetchall()
-                for track_id, listindex in track_ids:
-                    if self.stop_import_flag:
-                        break
-                    for track in tracks:
-                        if track[0] == track_id:
-                            media_file = self.expandMediaFile(track[1])
-                            self.addMediaFile(media_file, listindex)
-                            break
-            if self.stop_import_flag:
-                break
-            if not self.finish():
-                self.logError(self.import_source)
-
-    def getEncoding(self):
-        """
-        Detect character encoding of an openlp.org 1.x song database.
-        """
-        # Connect to the database.
-        connection = sqlite.connect(self.import_source.encode(
-            sys.getfilesystemencoding()), mode=0444)
-        cursor = connection.cursor()
-
-        detector = UniversalDetector()
-        # Detect charset by authors.
-        cursor.execute(u'SELECT authorname FROM authors')
-        authors = cursor.fetchall()
-        for author in authors:
-            detector.feed(author[0])
-            if detector.done:
-                detector.close()
-                return detector.result[u'encoding']
-        # Detect charset by songs.
-        cursor.execute(u'SELECT songtitle, copyrightinfo, '
-            u'lyrics || \'\' AS lyrics FROM songs')
-        songs = cursor.fetchall()
-        for index in [0, 1, 2]:
-            for song in songs:
-                detector.feed(song[index])
-                if detector.done:
-                    detector.close()
-                    return detector.result[u'encoding']
-        # Detect charset by songs.
-        cursor.execute(u'SELECT name FROM sqlite_master '
-            u'WHERE type = \'table\' AND name = \'tracks\'')
-        if cursor.fetchall():
-            cursor.execute(u'SELECT fulltrackname FROM tracks')
-            tracks = cursor.fetchall()
-            for track in tracks:
-                detector.feed(track[0])
-                if detector.done:
-                    detector.close()
-                    return detector.result[u'encoding']
-        detector.close()
-        return retrieve_windows_encoding(detector.result[u'encoding'])
-
-    def expandMediaFile(self, filename):
-        """
-        When you're on Windows, this function expands the file name to include
-        the path to OpenLP's application data directory. If you are not on
-        Windows, it returns the original file name.
-
-        ``filename``
-            The filename to expand.
-        """
-        if sys.platform != u'win32' and not os.environ.get(u'ALLUSERSPROFILE') and not os.environ.get(u'APPDATA'):
-            return filename
-        common_app_data = os.path.join(os.environ[u'ALLUSERSPROFILE'],
-            os.path.split(os.environ[u'APPDATA'])[1])
-        if not common_app_data:
-            return filename
-        return os.path.join(common_app_data, u'openlp.org', 'Audio', filename)
-
-    def _get_theme_manager(self):
-        """
-        Adds the theme manager to the class dynamically
-        """
-        if not hasattr(self, u'_theme_manager'):
-            self._theme_manager = Registry().get(u'theme_manager')
-        return self._theme_manager
-
-    theme_manager = property(_get_theme_manager)


Follow ups