Skip to content

Commit 10ffd4e

Browse files
authored
Merge pull request #61 from LeoBreebaart/master
Python package compatibiliy fixes
2 parents 40cf00d + 8b2cc58 commit 10ffd4e

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

iris/admin/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from datetime import timedelta
33

44
import flask
5+
import markupsafe
56
from sqlalchemy import func
67

78
from iris.user import requires_admin, requires_auth
@@ -44,7 +45,7 @@ def users():
4445
users_json = [user.to_json() for user in users]
4546

4647
html = flask.render_template('admin/users.html', users=users_json, order_by=order_by, ascending=ascending)
47-
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
48+
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))
4849

4950
@admin_app.route('/actions/<type>', methods=['GET'])
5051
@requires_auth
@@ -74,7 +75,7 @@ def actions(type):
7475
'admin/actions.html', action_type=type, actions=actions_json,
7576
image_stats=image_stats, order_by=order_by, ascending=ascending
7677
)
77-
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
78+
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))
7879

7980
@admin_app.route('/images', methods=['GET'])
8081
@requires_auth
@@ -117,4 +118,4 @@ def images():
117118
html = flask.render_template(
118119
'admin/images.html', images=images, order_by=order_by, ascending=ascending
119120
)
120-
return flask.render_template('admin/index.html', user=user, page=flask.Markup(html))
121+
return flask.render_template('admin/index.html', user=user, page=markupsafe.Markup(html))

iris/main/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import json
33

44
import flask
5+
import markupsafe
56
import numpy as np
67
from PIL import Image as PILImage
78
from skimage.transform import resize
@@ -92,7 +93,7 @@ def metadata(image_id):
9293

9394
if flask.request.args.get('safe_html', False):
9495
metadata = {
95-
k: flask.Markup(str(v))
96+
k: markupsafe.Markup(str(v))
9697
for k, v in metadata.items()
9798
}
9899

iris/project.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import re
1111

1212
import flask
13+
import markupsafe
14+
1315
import json
1416
from matplotlib import cm
1517
import numpy as np
@@ -95,7 +97,7 @@ def load_from(self, filename):
9597
# Make sure the HTML is understood in the descriptions:
9698
for name, view in self.config['views'].items():
9799
view['name'] = name
98-
view['description'] = flask.Markup(
100+
view['description'] = markupsafe.Markup(
99101
view.get('description', view['name'])
100102
)
101103
view['stretch'] = view.get('stretch', 'linear')

iris/segmentation/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def save_mask(image_id):
272272
# The user mask denotes who classified the pixels in the mask:
273273
# if true: the user classified the pixel
274274
# if false: the AI classified the pixel
275-
user_mask = data[1+mask_length:-1].astype(np.bool)
275+
user_mask = data[1+mask_length:-1].astype(bool)
276276
user_mask = user_mask.reshape(project['segmentation']['mask_shape'][::-1])
277277

278278
final_mask_file, user_mask_file = get_mask_filenames(image_id, user_id)

iris/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from copy import deepcopy
22

33
import flask
4-
4+
import markupsafe
55

66

77
class View:
@@ -12,8 +12,8 @@ def __init__(self, name, description, loader):
1212

1313
def to_json(self):
1414
return {
15-
'name': flask.Markup(self.name),
16-
'description': flask.Markup(self.description),
15+
'name': markupsafe.Markup(self.name),
16+
'description': markupsafe.Markup(self.description),
1717
}
1818

1919
def merge_deep_dicts(d1, d2):

0 commit comments

Comments
 (0)