Skip to content

Commit 878881d

Browse files
committed
Merge branch 'release/24.0.0'
2 parents b61d621 + d2f64bc commit 878881d

File tree

11 files changed

+103
-18
lines changed

11 files changed

+103
-18
lines changed

CHANGELOG

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
ChangeLog
33
*********
44

5+
24.0.0 (2024-01-02)
6+
===================
7+
- Fix: Install ca-certificates-java in Dockerfile to fix image build.
8+
- Fix: Support newer manifest locations for jamovi files (PR#369). (thanks, @jonathon-love!)
9+
- Fix: Support new manifest type and location for JASP-stats files. (thanks, @JorisGoosen and
10+
@RensDofferhoff!)
11+
512
23.1.0 (2023-04-17)
613
===================
714
- Fix: Improve support for special characters in tabular renderer sheet names. (thanks, @aaxelb!)

Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ RUN usermod -d /home www-data \
88
# -slim images strip man dirs, but java won't install unless this dir exists.
99
&& mkdir -p /usr/share/man/man1 \
1010
&& apt-get update \
11+
# HACK: work around bug in install java (dep of libreoffice)
12+
&& apt-get install -y ca-certificates-java \
1113
# mfr dependencies
1214
&& apt-get install -y \
1315
git \

mfr/extensions/jamovi/render.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,20 @@ def _check_file(self, zip_file):
6666
"""
6767
# Extract manifest file content
6868
try:
69-
with zip_file.open('META-INF/MANIFEST.MF') as manifest_data:
70-
manifest = manifest_data.read().decode('utf-8')
69+
try:
70+
# new manifest location
71+
with zip_file.open('meta') as manifest_data:
72+
manifest = manifest_data.read().decode('utf-8')
73+
except KeyError:
74+
# old manifest location
75+
with zip_file.open('META-INF/MANIFEST.MF') as manifest_data:
76+
manifest = manifest_data.read().decode('utf-8')
7177
except KeyError:
7278
raise jamovi_exceptions.JamoviFileCorruptError(
73-
'{} Missing META-INF/MANIFEST.MF'.format(self.MESSAGE_FILE_CORRUPT),
79+
'{} Missing manifest'.format(self.MESSAGE_FILE_CORRUPT),
7480
extension=self.metadata.ext,
7581
corruption_type='key_error',
76-
reason='zip missing ./META-INF/MANIFEST.MF',
82+
reason='zip missing manifest',
7783
)
7884

7985
lines = manifest.split('\n')

mfr/extensions/jasp/render.py

Lines changed: 57 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23

34
from mako.lookup import TemplateLookup
@@ -67,16 +68,30 @@ def _check_file(self, zip_file):
6768
"""
6869
# Extract manifest file content
6970
try:
70-
with zip_file.open('META-INF/MANIFEST.MF') as manifest_data:
71-
manifest = manifest_data.read().decode('utf-8')
71+
try:
72+
# new manifest location
73+
with zip_file.open('manifest.json') as manifest_data:
74+
manifest, flavor = manifest_data.read().decode('utf-8'), 'json'
75+
except KeyError:
76+
# old manifest location
77+
with zip_file.open('META-INF/MANIFEST.MF') as manifest_data:
78+
manifest, flavor = manifest_data.read().decode('utf-8'), 'java'
7279
except KeyError:
7380
raise exceptions.JaspFileCorruptError(
74-
'{} Missing META-INF/MANIFEST.MF'.format(self.MESSAGE_FILE_CORRUPT),
81+
'{} Missing manifest'.format(self.MESSAGE_FILE_CORRUPT),
7582
extension=self.metadata.ext,
7683
corruption_type='key_error',
77-
reason='zip missing ./META-INF/MANIFEST.MF',
84+
reason='zip missing manifest',
7885
)
7986

87+
if flavor == 'java':
88+
self._verify_java_manifest(manifest)
89+
else:
90+
self._verify_json_manifest(manifest)
91+
92+
return True
93+
94+
def _verify_java_manifest(self, manifest):
8095
lines = manifest.split('\n')
8196

8297
# Search for Data-Archive-Version
@@ -121,4 +136,41 @@ def _check_file(self, zip_file):
121136
reason='Data-Archive-Version ({}) not parsable.'.format(dataArchiveVersionStr),
122137
)
123138

124-
return True
139+
return
140+
141+
def _verify_json_manifest(self, manifest):
142+
143+
manifest_data = json.loads(manifest)
144+
145+
jasp_archive_version_str = manifest_data.get('jaspArchiveVersion', None)
146+
if not jasp_archive_version_str:
147+
raise exceptions.JaspFileCorruptError(
148+
'{} jaspArchiveVersion not found.'.format(self.MESSAGE_FILE_CORRUPT),
149+
extension=self.metadata.ext,
150+
corruption_type='manifest_parse_error',
151+
reason='jaspArchiveVersion not found.',
152+
)
153+
154+
# Check that the file is new enough (contains preview content)
155+
jasp_archive_version = LooseVersion(jasp_archive_version_str)
156+
try:
157+
if jasp_archive_version < self.MINIMUM_VERSION:
158+
minimum_version = self.MINIMUM_VERSION.vstring
159+
data_archive_version = jasp_archive_version.vstring
160+
raise exceptions.JaspVersionError(
161+
'This JASP file was created with an older data archive '
162+
'version ({}) and cannot be previewed. Minimum data archive '
163+
'version is {}.'.format(data_archive_version, minimum_version),
164+
extension=self.metadata.ext,
165+
actual_version=data_archive_version,
166+
required_version=minimum_version,
167+
)
168+
except TypeError:
169+
raise exceptions.JaspFileCorruptError(
170+
'{} jaspArchiveVersion not parsable.'.format(self.MESSAGE_FILE_CORRUPT),
171+
extension=self.metadata.ext,
172+
corruption_type='manifest_parse_error',
173+
reason='jaspArchiveVersion ({}) not parsable.'.format(jasp_archive_version_str),
174+
)
175+
176+
return

mfr/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '23.1.0'
1+
__version__ = '24.0.0'
Binary file not shown.

tests/extensions/jamovi/test_renderer.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ def metadata():
1515
'http://wb.osf.io/file/jamovi.omv?token=1337')
1616

1717
@pytest.fixture
18-
def ok_path():
19-
return os.path.join(BASE_PATH, 'ok.omv')
18+
def ok_new_manifest_path():
19+
return os.path.join(BASE_PATH, 'ok-new-manifest.omv')
20+
21+
@pytest.fixture
22+
def ok_old_manifest_path():
23+
return os.path.join(BASE_PATH, 'ok-old-manifest.omv')
2024

2125
@pytest.fixture
2226
def ok_with_image_path():
@@ -63,8 +67,8 @@ def extension():
6367
return '.omv'
6468

6569
@pytest.fixture
66-
def renderer(metadata, ok_path, url, assets_url, export_url):
67-
return JamoviRenderer(metadata, ok_path, url, assets_url, export_url)
70+
def renderer(metadata, ok_new_manifest_path, url, assets_url, export_url):
71+
return JamoviRenderer(metadata, ok_new_manifest_path, url, assets_url, export_url)
6872

6973

7074
class TestCodeJamoviRenderer:
@@ -73,6 +77,11 @@ def test_render_jamovi(self, renderer):
7377
body = renderer.render()
7478
assert '<div style="word-wrap: break-word; overflow: auto;" class="mfrViewer">' in body
7579

80+
def test_render_jamovi_old_manifest(self, metadata, ok_old_manifest_path, url, assets_url, export_url):
81+
renderer = JamoviRenderer(metadata, ok_old_manifest_path, url, assets_url, export_url)
82+
body = renderer.render()
83+
assert '<div style="word-wrap: break-word; overflow: auto;" class="mfrViewer">' in body
84+
7685
def test_render_jamovi_with_image(self, metadata, ok_with_image_path, url, assets_url,
7786
export_url):
7887
renderer = JamoviRenderer(metadata, ok_with_image_path, url, assets_url, export_url)
2.06 MB
Binary file not shown.

tests/extensions/jasp/test_renderer.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@ def metadata():
1111
return ProviderMetadata('JASP', '.jasp', 'application/octet-stream', '1234', 'http://wb.osf.io/file/JASP.jasp?token=1234')
1212

1313
@pytest.fixture
14-
def ok_path():
15-
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files', 'ok.jasp')
14+
def ok_old_manifest_path():
15+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files', 'ok-old-manifest.jasp')
16+
17+
@pytest.fixture
18+
def ok_new_manifest_path():
19+
return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'files', 'ok-new-manifest.jasp')
1620

1721
@pytest.fixture
1822
def not_a_zip_file_path():
@@ -60,8 +64,8 @@ def extension():
6064

6165

6266
@pytest.fixture
63-
def renderer(metadata, ok_path, url, assets_url, export_url):
64-
return JASPRenderer(metadata, ok_path, url, assets_url, export_url)
67+
def renderer(metadata, ok_new_manifest_path, url, assets_url, export_url):
68+
return JASPRenderer(metadata, ok_new_manifest_path, url, assets_url, export_url)
6569

6670

6771
class TestCodeJASPRenderer:
@@ -70,6 +74,11 @@ def test_render_JASP(self, renderer):
7074
body = renderer.render()
7175
assert '<div style="word-wrap: break-word; overflow: auto;" class="mfrViewer">' in body
7276

77+
def test_render_JASP_old_manifest(self, metadata, ok_old_manifest_path, url, assets_url, export_url):
78+
renderer = JASPRenderer(metadata, ok_old_manifest_path, url, assets_url, export_url)
79+
body = renderer.render()
80+
assert '<div style="word-wrap: break-word; overflow: auto;" class="mfrViewer">' in body
81+
7382
def test_render_JASP_not_a_zip_file(self, metadata, not_a_zip_file_path, url, assets_url, export_url):
7483
try:
7584
renderer = JASPRenderer(metadata, not_a_zip_file_path, url, assets_url, export_url)

0 commit comments

Comments
 (0)