From d60ea23de63b1e0d64c084857d81fe20477daa37 Mon Sep 17 00:00:00 2001 From: Tomas Groth Date: Fri, 5 May 2017 20:48:01 +0200 Subject: [PATCH] Try to fix songbeamer chord imports --- openlp/plugins/songs/lib/importers/songbeamer.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/openlp/plugins/songs/lib/importers/songbeamer.py b/openlp/plugins/songs/lib/importers/songbeamer.py index 8c3765ff5..f54185b07 100644 --- a/openlp/plugins/songs/lib/importers/songbeamer.py +++ b/openlp/plugins/songs/lib/importers/songbeamer.py @@ -112,6 +112,7 @@ class SongBeamerImport(SongImport): self.current_verse = '' self.current_verse_type = VerseType.tags[VerseType.Verse] self.chord_table = None + self.editor_version = 0 file_name = os.path.split(import_file)[1] if os.path.isfile(import_file): # Detect the encoding @@ -143,7 +144,7 @@ class SongBeamerImport(SongImport): self.current_verse_type = VerseType.tags[VerseType.Verse] read_verses = True verse_start = True - # Songbeamer allows chord on line "-1" + # Songbeamer allows chord on line "-1", meaning the first line has only chords if line_number == -1: first_line = self.insert_chords(line_number, '') if first_line: @@ -160,6 +161,8 @@ class SongBeamerImport(SongImport): line = self.insert_chords(line_number, line) self.current_verse += line.strip() + '\n' line_number += 1 + elif self.editor_version < 4: + line_number += 1 else: line = self.insert_chords(line_number, line) self.current_verse += line.strip() + '\n' @@ -241,7 +244,10 @@ class SongBeamerImport(SongImport): except ValueError: self.comments = tag_val[1] elif tag_val[0] == '#Editor': - pass + try: + self.editor_version = float(re.sub('[a-zA-Z ]', '', tag_val[1])) + except ValueError: + self.editor_version = 0 elif tag_val[0] == '#Font': pass elif tag_val[0] == '#FontLang2':