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
d59ea249
Commit
d59ea249
authored
Aug 16, 2012
by
Clément Schreiner
Browse files
PEP8 compliance.
parent
a33bfcf9
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/api.py
View file @
d59ea249
...
...
@@ -77,6 +77,7 @@ def importercmd(func):
func
.
importercmd
=
True
return
func
def
test_result
(
cls
):
"""
Makes a plugin result model the result of a QA test.
...
...
@@ -91,6 +92,7 @@ def test_result(cls):
# FIXME: move this somewhere else
# FIXME: some of that could be abstracted
def
bool_field
(
name
):
""" Property exposing a string ('true' or 'false') as a bool. """
def
fget
(
instance
):
...
...
@@ -108,6 +110,7 @@ def bool_field(name):
"Read-write property exposing a string ('true' or 'false')"
" as a bool."
)
def
int_field
(
name
):
""" Property exposing a string as an int """
def
fget
(
instance
):
...
...
@@ -123,10 +126,13 @@ def int_field(name):
return
property
(
fget
,
fset
,
fdel
,
'Read-write property exposing a string as an int'
)
#
# Bases classes for plugins
#
class
BasePlugin
(
object
):
"""
Base class for importer plugins.
...
...
@@ -146,7 +152,6 @@ class BasePlugin(object):
if
models
is
not
None
:
self
.
_load_models
(
models
)
# for storing results retrieved from the database
self
.
results
=
{}
...
...
@@ -154,7 +159,6 @@ class BasePlugin(object):
for
key
in
kw
:
setattr
(
self
,
key
,
kw
[
key
])
# sqlalchemy session
self
.
session
=
session
...
...
@@ -174,7 +178,7 @@ class BasePlugin(object):
"""
for
model
in
self
.
models
:
q
=
self
.
session
.
query
(
model
)
q
=
q
.
filter_by
(
package_version
=
self
.
package_version
)
q
=
q
.
filter_by
(
package_version
=
self
.
package_version
)
for
result
in
q
.
all
():
self
.
_load_result
(
result
)
...
...
@@ -194,7 +198,7 @@ class BasePlugin(object):
Add a new result to the list of db objects. Returns the
instance of the result.
"""
result
=
result_cls
(
package_version
=
self
.
package_version
)
result
=
result_cls
(
package_version
=
self
.
package_version
)
for
k
,
v
in
data
.
iteritems
():
result
[
k
]
=
v
...
...
@@ -218,7 +222,7 @@ class BasePlugin(object):
]
lookup
=
TemplateLookup
(
directories
=
PLUGINS_TEMPLATE_DIRS
,
directories
=
PLUGINS_TEMPLATE_DIRS
,
input_encoding
=
'utf-8'
,
output_encoding
=
'utf-8'
,
)
...
...
@@ -263,10 +267,11 @@ class BasePlugin(object):
"""Render the plugin data to the given format"""
template
=
self
.
_find_template
(
self
.
name
,
render_format
)
return
template
.
render_unicode
(
results
=
self
.
results
,
h
=
helpers
,
return
template
.
render_unicode
(
results
=
self
.
results
,
h
=
helpers
,
**
render_args
)
class
QAPlugin
(
BasePlugin
):
"""
Class for implementing QA plugins.
...
...
@@ -286,7 +291,7 @@ class QAPlugin(BasePlugin):
# the PluginResult-derived class representing the result of the
# test
test_model
=
None
test_result
=
None
# instance of that class, set by ``load``
test_result
=
None
# instance of that class, set by ``load``
@
property
def
test_severity
(
self
):
...
...
@@ -316,7 +321,7 @@ class QAPlugin(BasePlugin):
Render the QA test's template.
"""
return
super
(
QAPlugin
,
self
).
render
(
render_format
,
test_result
=
self
.
test_result
,
test_result
=
self
.
test_result
,
**
render_args
)
def
_load_model
(
self
,
model
):
...
...
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