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
1efa4c59
Commit
1efa4c59
authored
Jul 11, 2012
by
Clément Schreiner
Browse files
Merge branch 'plugin-api' into semantic-review
parents
34fc074a
45301aed
Changes
3
Hide whitespace changes
Inline
Side-by-side
debexpo/model/plugin_results.py
View file @
1efa4c59
...
...
@@ -40,7 +40,7 @@ from debexpo.model.package_versions import PackageVersion
t_plugin_results
=
sa
.
Table
(
'plugin_results'
,
meta
.
metadata
,
sa
.
Column
(
'id'
,
sa
.
types
.
Integer
,
primary_key
=
True
),
sa
.
Column
(
'
plugin
'
,
sa
.
types
.
String
(
200
)),
sa
.
Column
(
'
entity
'
,
sa
.
types
.
String
(
200
)),
sa
.
Column
(
'package_version_id'
,
sa
.
types
.
Integer
,
sa
.
ForeignKey
(
'package_versions.id'
),
...
...
@@ -64,7 +64,7 @@ class PluginResultData(OrmObject):
plugin_result_mapper
=
orm
.
mapper
(
PluginResult
,
t_plugin_results
,
polymorphic_on
=
t_plugin_results
.
c
.
plugin
,
polymorphic_on
=
t_plugin_results
.
c
.
entity
,
polymorphic_identity
=
'plugin_results'
,
properties
=
{
'package_version'
:
orm
.
relation
(
PackageVersion
,
...
...
debexpo/plugins/__init__.py
View file @
1efa4c59
...
...
@@ -41,8 +41,9 @@ from debexpo.model.plugin_results import PluginResultData
class
BasePlugin
(
object
):
result_model
=
None
"""
Base class for importer plugins.
"""
def
__init__
(
self
,
package_version
,
**
kw
):
self
.
_db_objects
=
[]
self
.
package_version
=
package_version
...
...
@@ -58,14 +59,15 @@ class BasePlugin(object):
def
_add_db_objects
(
self
,
*
db_objects
):
self
.
_db_objects
.
extend
(
db_objects
)
# TODO/NOTE: maybe we should do this into PluginResult? (through an association proxy?)
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
)
def
_new_result
(
self
,
result_cls
,
**
data
):
result
=
result_
cls
(
package_version
=
self
.
package_version
)
self
.
_add_db_objects
(
result
)
self
.
_add_data
(
result
,
**
data
)
return
result
...
...
debexpo/plugins/native.py
View file @
1efa4c59
...
...
@@ -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'
,
...
...
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