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
2c244780
Commit
2c244780
authored
Aug 17, 2012
by
Clément Schreiner
Browse files
Updated the controlfields plugin. Not yet tested.
parent
4c7930dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/controlfields.py
View file @
2c244780
...
...
@@ -45,19 +45,49 @@ from debian import deb822
import
logging
from
debexpo.lib
import
constants
from
debexpo.plugins
import
BasePlugin
from
debexpo.plugins.api
import
*
from
debexpo.model
import
meta
log
=
logging
.
getLogger
(
__name__
)
fields
=
[
'Homepage'
,
'Vcs-Browser'
,
'Vcs-Git'
,
'Vcs-Svn'
,
'Vcs-Bzr'
,
'Vcs-Hg'
]
class
ControlFieldsPlugin
(
BasePlugin
):
@
test_result
class
ControlfieldTest
(
PluginResult
):
""" Result of the control fields plugin """
homepage
=
bool_field
(
'homepage'
)
vcs
=
bool_field
(
'vcs'
)
def
get_fields
(
self
):
q
=
meta
.
session
.
query
(
ControlField
)
q
=
q
.
filter_by
(
package_version
=
self
.
package_version
)
return
dict
((
f
.
field
,
f
.
value
)
for
f
in
q
.
all
())
def
__str__
(
self
):
if
self
.
homepage
:
return
'Homepage {vcs} control field{s} present'
.
format
(
vcs
=
'and VCS'
if
self
.
vcs
else
''
,
s
=
's'
if
self
.
vcs
else
''
)
class
ControlField
(
PluginResult
):
""" Additional debian/control field """
field
=
string_field
(
'field'
)
value
=
string_field
(
'data'
)
class
ControlFieldsPlugin
(
QAPlugin
):
@
importercmd
def
test_control_fields
(
self
):
"""
Checks whether additional debian/control fields are present.
"""
log
.
debug
(
'Checking whether additional debian/control fields are present'
)
log
.
debug
(
'Checking whether additional debian/control'
'fields are present'
)
try
:
dsc
=
deb822
.
Dsc
(
file
(
self
.
changes
.
get_dsc
()))
...
...
@@ -65,21 +95,26 @@ class ControlFieldsPlugin(BasePlugin):
log
.
critical
(
'Could not open dsc file; skipping plugin'
)
return
data
=
{}
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
outcome
=
"No Homepage field present"
found_homepage
=
False
for
item
in
fields
:
if
item
in
dsc
:
data
[
item
]
=
dsc
[
item
]
if
item
==
'Homepage'
:
found_homepage
=
True
self
.
new_result
(
ControlField
,
field
=
item
,
value
=
dsc
[
item
])
if
"Homepage"
in
data
:
severity
=
constants
.
PLUGIN_SEVERITY_INFO
if
len
(
data
)
>
1
:
outcome
=
"Homepage and VCS control fields present"
else
:
outcome
=
"Homepage control field present"
if
found_homepage
:
test_result
=
self
.
new_test_result
(
severity
=
constants
.
PLUGIN_SEVERITY_INFO
)
test_result
.
homepage
=
True
self
.
failed
(
outcome
,
data
,
severity
)
if
len
(
self
.
results
)
>
1
:
test_result
.
vcs
=
True
plugin
=
ControlFieldsPlugin
models
=
[
ControlfieldTest
,
ControlField
,
]
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