Commit 68894ede authored by Clément Schreiner's avatar Clément Schreiner
Browse files

New method in BasePlugin: _new_result (update to new model).

parent 6723100c
......@@ -37,6 +37,8 @@ __license__ = 'MIT'
from debexpo.lib import constants
from debexpo.model.plugin_results import PluginResultData
class BasePlugin(object):
result_model = None
......@@ -56,13 +58,18 @@ class BasePlugin(object):
def _add_db_objects(self, *db_objects):
self._db_objects.extend(db_objects)
def _add_data(self, id=0, **data):
result_data = [self.result_model(package_version_id = self.package_version.id,
id = id,
def _add_data(self, result, **data):
result_data = [PluginResultData(plugin_result = result,
key = key,
value = data[key]) for key in data]
self._add_db_objects(*result_data)
def _new_result(self, **data):
result = self.result_model(package_version = self.package_version)
self._add_db_objects(result)
self._add_data(result, **data)
return result
@property
def db_objects(self):
return self._db_objects
......@@ -67,14 +67,15 @@ class NativePlugin(BasePlugin):
native = filecheck.is_native_package(self.changes)
result = self._new_result()
if 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(native = 'true')
self._add_data(result, native = 'true')
else:
log.debug('Package is not native')
self._add_data(native = 'false',
severity = constants.PLUGIN_SEVERITY_INFO)
self._add_data(result, native = 'false',
severity = constants.PLUGIN_SEVERITY_INFO)
plugin = NativePlugin
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