Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Commit

Permalink
Only use simple json for Jarvis, newer versions won't need it
Browse files Browse the repository at this point in the history
  • Loading branch information
razzeee committed Jan 20, 2017
1 parent 805ec12 commit 83c38e5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
2 changes: 1 addition & 1 deletion generators/app/templates/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<requires>
<import addon="xbmc.python" version="<%= props.kodiVersion %>"/>
<%_ if (props.type == 'Plugin') { -%> <import addon="script.module.routing" version="0.2.0"/><% } %>
<%_ if (props.type == 'Plugin' || props.type == 'Script' || props.type == 'Service') { -%> <import addon="script.module.simplejson" version="3.3.0"/><% } %>
<%_ if (props.kodiVersion == '2.24.0' && (props.type == 'Plugin' || props.type == 'Script' || props.type == 'Service')) { -%> <import addon="script.module.simplejson" version="3.3.0"/><% } %>
</requires>
<% if (props.type == 'Contextmenu') { -%><extension point="kodi.context.item" library="context.py">
<item>
Expand Down
5 changes: 4 additions & 1 deletion generators/app/templates/resources/lib/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
import sys
import logging


<%_ if (props.kodiVersion == '2.24.0') { -%>
if sys.version_info >= (2, 7):
import json as json
else:
import simplejson as json
<%_ } else { -%>
import json as json
<% } %>

# read settings
ADDON = xbmcaddon.Addon('<%= props.scriptid %>')
Expand Down
33 changes: 31 additions & 2 deletions test/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ describe('generate plugin', function () {
assert.fileContent('addon.xml', '<import addon="xbmc.python" version="2.25.0"/>');
assert.fileContent('addon.xml', '<provides>video</provides>');
assert.fileContent('addon.xml', '<import addon="script.module.routing" version="');
assert.fileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.noFileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.noFileContent('resources/lib/utilities.py', 'import simplejson as json');
});
});

Expand Down Expand Up @@ -268,7 +269,8 @@ describe('generate script', function () {
assert.fileContent('addon.xml', '<platform>all</platform>');
assert.fileContent('addon.xml', '<import addon="xbmc.python" version="2.25.0"/>');
assert.fileContent('addon.xml', '<provides>executable</provides>');
assert.fileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.noFileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.noFileContent('resources/lib/utilities.py', 'import simplejson as json');
});
});

Expand Down Expand Up @@ -324,6 +326,33 @@ describe('generate service', function () {
assert.fileContent('addon.xml', ' provider-name="Me">');
assert.fileContent('addon.xml', '<platform>all</platform>');
assert.fileContent('addon.xml', '<import addon="xbmc.python" version="2.25.0"/>');
assert.noFileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.noFileContent('resources/lib/utilities.py', 'import simplejson as json');
});
});

describe('check simplejson for jarvis', function () {
before(function () {
return helpers.run(path.join(__dirname, '../generators/app'))
.withPrompts({
type: 'Service',
scriptid: 'service.test',
start: 'login',
scriptname: 'My service name',
kodiVersion: '2.24.0',
platforms: 'all',
license: 'MIT',
authors: 'Me',
summary: 'My summary',
authorName: 'My real name',
email: 'test@test.de',
website: 'www.kodi.tv'
})
.toPromise();
});

it('check service addon.xml content', function () {
assert.fileContent('addon.xml', '<import addon="script.module.simplejson" version="');
assert.fileContent('resources/lib/utilities.py', 'import simplejson as json');
});
});

0 comments on commit 83c38e5

Please sign in to comment.