Merge lp:~tomasgroth/openlp/py35 into lp:openlp/2.2

Proposed by Tomas Groth
Status: Merged
Merged at revision: 2564
Proposed branch: lp:~tomasgroth/openlp/py35
Merge into: lp:openlp/2.2
Diff against target: 101 lines (+29/-11)
2 files modified
openlp/plugins/bibles/lib/http.py (+2/-3)
openlp/plugins/songs/lib/songselect.py (+27/-8)
To merge this branch: bzr merge lp:~tomasgroth/openlp/py35
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Tim Bentley Approve
Review via email: mp+275460@code.launchpad.net

This proposal supersedes a proposal from 2015-10-19.

Description of the change

Make OpenLP run on Python 3.3-3.5

To post a comment you must log in.
Revision history for this message
Tomas Groth (tomasgroth) wrote : Posted in a previous version of this proposal

lp:~tomasgroth/openlp/py35 (revision 2565)
[SUCCESS] https//ci.openlp.io/job/Branch-01-Pull/1152/
[SUCCESS] https//ci.openlp.io/job/Branch-02-Functional-Tests/1075/
[SUCCESS] https//ci.openlp.io/job/Branch-03-Interface-Tests/1016/
[SUCCESS] https//ci.openlp.io/job/Branch-04a-Windows_Functional_Tests/863/
[SUCCESS] https//ci.openlp.io/job/Branch-04b-Windows_Interface_Tests/460/
[SUCCESS] https//ci.openlp.io/job/Branch-05a-Code_Analysis/581/
[SUCCESS] https//ci.openlp.io/job/Branch-05b-Test_Coverage/452/

Revision history for this message
Tim Bentley (trb143) wrote : Posted in a previous version of this proposal

Unable to test but makes sense.

review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote : Posted in a previous version of this proposal

Please don't merge this until my approval. I want to look at a few things first.

Revision history for this message
Tim Bentley (trb143) :
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

I'm not sure if we should do this with 2.2. I'm more than happy to be convinced otherwise though.

Revision history for this message
Tomas Groth (tomasgroth) wrote :

> I'm not sure if we should do this with 2.2. I'm more than happy to be
> convinced otherwise though.
I'll try to convince you then :)
I think this should in particular should go into 2.2. The 2.4 release is 6-8 months away, which means that 2.2 should be able to be used until then. New releases of ubuntu and other distros will include python 3.5, so we need to support it if OpenLP is to run on those distros.
For 2.4 I think we should drop support for python 3.3.

Revision history for this message
Raoul Snyman (raoul-snyman) wrote :

OK, I'm convinced.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'openlp/plugins/bibles/lib/http.py'
2--- openlp/plugins/bibles/lib/http.py 2015-09-08 19:13:59 +0000
3+++ openlp/plugins/bibles/lib/http.py 2015-10-22 21:08:23 +0000
4@@ -27,7 +27,6 @@
5 import socket
6 import urllib.parse
7 import urllib.error
8-from html.parser import HTMLParseError
9
10 from bs4 import BeautifulSoup, NavigableString, Tag
11
12@@ -290,7 +289,7 @@
13 page_source = str(page_source, 'cp1251')
14 try:
15 soup = BeautifulSoup(page_source)
16- except HTMLParseError:
17+ except Exception:
18 log.error('BeautifulSoup could not parse the Bible page.')
19 send_error_message('parse')
20 return None
21@@ -762,7 +761,7 @@
22 try:
23 soup = BeautifulSoup(page_source)
24 CLEANER_REGEX.sub('', str(soup))
25- except HTMLParseError:
26+ except Exception:
27 log.exception('BeautifulSoup could not parse the bible page.')
28 if not soup:
29 send_error_message('parse')
30
31=== modified file 'openlp/plugins/songs/lib/songselect.py'
32--- openlp/plugins/songs/lib/songselect.py 2015-07-04 21:09:59 +0000
33+++ openlp/plugins/songs/lib/songselect.py 2015-10-22 21:08:23 +0000
34@@ -23,10 +23,13 @@
35 The :mod:`~openlp.plugins.songs.lib.songselect` module contains the SongSelect importer itself.
36 """
37 import logging
38+import sys
39 from http.cookiejar import CookieJar
40 from urllib.parse import urlencode
41 from urllib.request import HTTPCookieProcessor, URLError, build_opener
42 from html.parser import HTMLParser
43+if sys.version_info > (3, 4):
44+ from html import unescape
45
46
47 from bs4 import BeautifulSoup, NavigableString
48@@ -129,11 +132,18 @@
49 if not search_results:
50 break
51 for result in search_results:
52- song = {
53- 'title': self.html_parser.unescape(result.find('h3').string),
54- 'authors': [self.html_parser.unescape(author.string) for author in result.find_all('li')],
55- 'link': BASE_URL + result.find('a')['href']
56- }
57+ if sys.version_info > (3, 4):
58+ song = {
59+ 'title': unescape(result.find('h3').string),
60+ 'authors': [unescape(author.string) for author in result.find_all('li')],
61+ 'link': BASE_URL + result.find('a')['href']
62+ }
63+ else:
64+ song = {
65+ 'title': self.html_parser.unescape(result.find('h3').string),
66+ 'authors': [self.html_parser.unescape(author.string) for author in result.find_all('li')],
67+ 'link': BASE_URL + result.find('a')['href']
68+ }
69 if callback:
70 callback(song)
71 songs.append(song)
72@@ -167,7 +177,10 @@
73 if callback:
74 callback()
75 song['copyright'] = '/'.join([li.string for li in song_page.find('ul', 'copyright').find_all('li')])
76- song['copyright'] = self.html_parser.unescape(song['copyright'])
77+ if sys.version_info > (3, 4):
78+ song['copyright'] = unescape(song['copyright'])
79+ else:
80+ song['copyright'] = self.html_parser.unescape(song['copyright'])
81 song['ccli_number'] = song_page.find('ul', 'info').find('li').string.split(':')[1].strip()
82 song['verses'] = []
83 verses = lyrics_page.find('section', 'lyrics').find_all('p')
84@@ -180,9 +193,15 @@
85 else:
86 verse['lyrics'] += '\n'
87 verse['lyrics'] = verse['lyrics'].strip(' \n\r\t')
88- song['verses'].append(self.html_parser.unescape(verse))
89+ if sys.version_info > (3, 4):
90+ song['verses'].append(unescape(verse))
91+ else:
92+ song['verses'].append(self.html_parser.unescape(verse))
93 for counter, author in enumerate(song['authors']):
94- song['authors'][counter] = self.html_parser.unescape(author)
95+ if sys.version_info > (3, 4):
96+ song['authors'][counter] = unescape(author)
97+ else:
98+ song['authors'][counter] = self.html_parser.unescape(author)
99 return song
100
101 def save_song(self, song):

Subscribers

People subscribed via source and target branches

to all changes: