Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mentors.debian.net
debexpo
Commits
cc1044b6
Commit
cc1044b6
authored
Jul 08, 2012
by
Clément Schreiner
Browse files
Merge branch 'plugin-api' into semantic-review
Conflicts: debexpo/model/plugin_results.py
parents
3805fd0e
7a8a8184
Changes
3
Hide whitespace changes
Inline
Side-by-side
debexpo/model/plugin_results.py
View file @
cc1044b6
...
...
@@ -33,22 +33,34 @@ Holds plugin_results table model.
from
sqlalchemy
import
orm
import
sqlalchemy
as
sa
from
sqlalchemy.orm.collections
import
attribute_mapped_collection
from
debexpo.model
import
meta
,
OrmObject
from
debexpo.model.package_versions
import
PackageVersion
t_plugin_results
=
sa
.
Table
(
'plugin_results'
,
meta
.
metadata
,
sa
.
Column
(
'plugin'
,
sa
.
types
.
String
(
200
),
primary_key
=
True
),
sa
.
Column
(
'package_version_id'
,
sa
.
types
.
Integer
,
sa
.
ForeignKey
(
'package_versions.id'
),
primary_key
=
True
),
sa
.
Column
(
'id'
,
sa
.
types
.
Integer
,
primary_key
=
True
),
sa
.
Column
(
'key'
,
sa
.
types
.
String
(
200
),
primary_key
=
True
),
sa
.
Column
(
'value'
,
sa
.
types
.
Text
()),
sa
.
Column
(
'plugin'
,
sa
.
types
.
String
(
200
)),
sa
.
Column
(
'package_version_id'
,
sa
.
types
.
Integer
,
sa
.
ForeignKey
(
'package_versions.id'
),
nullable
=
False
),
)
t_plugin_result_data
=
sa
.
Table
(
'plugin_result_data'
,
meta
.
metadata
,
sa
.
Column
(
'plugin_result_id'
,
sa
.
ForeignKey
(
'plugin_results.id'
),
primary_key
=
True
),
sa
.
Column
(
'key'
,
sa
.
types
.
String
(
200
),
primary_key
=
True
),
sa
.
Column
(
'value'
,
sa
.
types
.
Text
()),
)
class
PluginResult
(
OrmObject
):
foreign
=
[
'package_info'
]
foreign
=
[
'package_version'
]
class
PluginResultData
(
OrmObject
):
foreign
=
[
'plugin_results'
]
plugin_result_mapper
=
orm
.
mapper
(
PluginResult
,
t_plugin_results
,
...
...
@@ -56,7 +68,16 @@ plugin_result_mapper = orm.mapper(PluginResult,
polymorphic_identity
=
'plugin_results'
,
properties
=
{
'package_version'
:
orm
.
relation
(
PackageVersion
,
backref
=
'plugin_results'
),
backref
=
'plugin_results'
,
),
}
)
plugin_result_data_mapper
=
orm
.
mapper
(
PluginResultData
,
t_plugin_result_data
,
properties
=
{
'plugin_result'
:
orm
.
relation
(
PluginResult
,
backref
=
orm
.
backref
(
'data'
,
collection_class
=
attribute_mapped_collection
(
'key'
))
)
}
)
debexpo/plugins/__init__.py
View file @
cc1044b6
...
...
@@ -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
debexpo/plugins/native.py
View file @
cc1044b6
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment