bugfixing

This commit is contained in:
rimach 2010-09-29 22:37:52 +02:00
parent d249b2a326
commit 345a94381a
2 changed files with 19 additions and 18 deletions

View File

@ -133,13 +133,7 @@ class AppLocation(object):
path = os.path.join(os.getenv(u'HOME'), u'.openlp') path = os.path.join(os.getenv(u'HOME'), u'.openlp')
return path return path
elif dir_type == AppLocation.DataDir: elif dir_type == AppLocation.DataDir:
settings = QtCore.QSettings() if sys.platform == u'win32':
settings.beginGroup(u'general')
extDbPath = settings.value(u'ext db path', QtCore.QVariant(u'')).toString()
if settings.value(u'ext db usage', QtCore.QVariant(False)).toBool()\
and QtCore.QDir(extDbPath).exists():
path = os.path.abspath(str(settings.value(u'ext db path', QtCore.QVariant(u'')).toString()))
elif sys.platform == u'win32':
path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data') path = os.path.join(os.getenv(u'APPDATA'), u'openlp', u'data')
elif sys.platform == u'darwin': elif sys.platform == u'darwin':
path = os.path.join(os.getenv(u'HOME'), u'Library', path = os.path.join(os.getenv(u'HOME'), u'Library',

View File

@ -27,9 +27,11 @@
The :mod:`songbeamerimport` module provides the functionality for importing The :mod:`songbeamerimport` module provides the functionality for importing
SongBeamer songs into the OpenLP database. SongBeamer songs into the OpenLP database.
""" """
import logging
import os import os
import re import re
import logging import chardet
import codecs
from openlp.plugins.songs.lib.songimport import SongImport from openlp.plugins.songs.lib.songimport import SongImport
@ -58,12 +60,13 @@ class SongBeamerTypes(object):
class SongBeamerImport(SongImport): class SongBeamerImport(SongImport):
""" """
Import Song Beamer files(s)
Song Beamer file format is text based
in the beginning are one or more control tags written
""" """
def __init__(self, master_manager, **kwargs): def __init__(self, master_manager, **kwargs):
""" """
Initialise the import. Initialise the import.
``master_manager`` ``master_manager``
The song manager for the running OpenLP installation. The song manager for the running OpenLP installation.
""" """
@ -79,7 +82,6 @@ class SongBeamerImport(SongImport):
""" """
Recieve a single file, or a list of files to import. Recieve a single file, or a list of files to import.
""" """
if isinstance(self.import_source, list): if isinstance(self.import_source, list):
self.import_wizard.importProgressBar.setMaximum( self.import_wizard.importProgressBar.setMaximum(
len(self.import_source)) len(self.import_source))
@ -90,11 +92,16 @@ class SongBeamerImport(SongImport):
self.file_name = os.path.split(file)[1] self.file_name = os.path.split(file)[1]
self.import_wizard.incrementProgressBar( self.import_wizard.incrementProgressBar(
"Importing %s" % (self.file_name), 0) "Importing %s" % (self.file_name), 0)
self.songFile = open(file, 'r') if os.path.isfile(file):
self.songData = self.songFile.read().decode('utf8') detect_file = open(file, u'r')
self.songData = self.songData.splitlines() details = chardet.detect(detect_file.read(2048))
self.songFile.close() detect_file.close()
infile = codecs.open(file, u'r', details['encoding'])
self.songData = infile.readlines()
else:
return False
for line in self.songData: for line in self.songData:
line = line.strip()
if line.startswith('#'): if line.startswith('#'):
log.debug(u'find tag: %s' % line) log.debug(u'find tag: %s' % line)
if not self.parse_tags(line): if not self.parse_tags(line):
@ -102,7 +109,8 @@ class SongBeamerImport(SongImport):
elif line.startswith('---'): elif line.startswith('---'):
log.debug(u'find ---') log.debug(u'find ---')
if len(self.current_verse) > 0: if len(self.current_verse) > 0:
self.add_verse(self.current_verse, self.current_verse_type) self.add_verse(self.current_verse,
self.current_verse_type)
self.current_verse = u'' self.current_verse = u''
self.current_verse_type = u'V' self.current_verse_type = u'V'
self.read_verse = True self.read_verse = True
@ -137,7 +145,7 @@ class SongBeamerImport(SongImport):
elif tag_val[0] == '#Bible': elif tag_val[0] == '#Bible':
pass pass
elif tag_val[0] == '#Categories': elif tag_val[0] == '#Categories':
pass self.topics = line.split(',')
elif tag_val[0] == '#CCLI': elif tag_val[0] == '#CCLI':
self.ccli_number = tag_val[1] self.ccli_number = tag_val[1]
elif tag_val[0] == '#Chords': elif tag_val[0] == '#Chords':
@ -218,7 +226,6 @@ class SongBeamerImport(SongImport):
pass pass
return True return True
def check_verse_marks(self, line): def check_verse_marks(self, line):
marks = line.split(' ') marks = line.split(' ')
if len(marks) <= 2 and \ if len(marks) <= 2 and \