Commit 45301aed authored by Clément Schreiner's avatar Clément Schreiner
Browse files

Update for last model changes + small improvements.

parent 5d5e7015
......@@ -49,15 +49,29 @@ from sqlalchemy import orm
log = logging.getLogger(__name__)
class NativeResult(PluginResult):
pass
class NativeTest(PluginResult):
"""
Result of the 'native' plugin for a package.
"""
@property
def is_native(self):
return self.data['native'].value == 'true'
orm.mapper(NativeResult, inherits=plugin_result_mapper,
polymorphic_identity = 'native')
@property
def severity(self):
s = self.data.get('severity', None)
return s if s is None else s.value
class NativePlugin(BasePlugin):
result_model = NativeResult
def __repr__(self):
return 'Package is%s native' % (' ' if self.is_native else ' not')
orm.mapper(NativeTest, inherits=plugin_result_mapper,
polymorphic_identity = 'native_test')
class NativePlugin(BasePlugin):
"""
Plugin checking whether a package is a native package.
"""
def test_native(self):
"""
Test to see whether the package is a native package.
......@@ -65,14 +79,15 @@ class NativePlugin(BasePlugin):
log.debug('Checking whether the package is native or not')
filecheck = filesystem.CheckFiles()
native = filecheck.is_native_package(self.changes)
is_native = filecheck.is_native_package(self.changes)
result = self._new_result()
if native:
result = self._new_result(NativeTest)
if is_native:
# Most uploads will not be native, and especially on mentors, a native
# package is almost probably in error.
log.warning('Package is native')
self._add_data(result, native = 'true')
self._add_data(result, native = 'true',
severity = constants.PLUGIN_SEVERITY_WARNING)
else:
log.debug('Package is not native')
self._add_data(result, native = 'false',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment