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
453b4b8d
Commit
453b4b8d
authored
Feb 15, 2012
by
Nicolas Dandrimont
🤔
Browse files
Overhaul the controlfields plugin
parent
2e933700
Changes
3
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/controlfields.py
View file @
453b4b8d
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
#
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
# Copyright © 2010 Jan Dittberner <jandd@debian.org>
# Copyright © 2012 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
#
#
# Permission is hereby granted, free of charge, to any person
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# obtaining a copy of this software and associated documentation
...
@@ -33,28 +34,23 @@ Holds the controlfields plugin.
...
@@ -33,28 +34,23 @@ Holds the controlfields plugin.
"""
"""
__author__
=
'Jonny Lamb'
__author__
=
'Jonny Lamb'
__copyright__
=
'Copyright © 2008 Jonny Lamb, Copyright © 2010 Jan Dittberner'
__copyright__
=
', '
.
join
([
'Copyright © 2008 Jonny Lamb'
,
'Copyright © 2010 Jan Dittberner'
,
'Copyright © 2012 Nicolas Dandrimont'
,
])
__license__
=
'MIT'
__license__
=
'MIT'
from
debian
import
deb822
from
debian
import
deb822
import
logging
import
logging
from
debexpo.lib
import
constants
from
debexpo.plugins
import
BasePlugin
from
debexpo.plugins
import
BasePlugin
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
fields
=
[
'Homepage'
,
'Vcs-Browser'
,
'Vcs-Git'
,
'Vcs-Svn'
,
'Vcs-Bzr'
,
'Vcs-Hg'
]
fields
=
[
'Homepage'
,
'Vcs-Browser'
,
'Vcs-Git'
,
'Vcs-Svn'
,
'Vcs-Bzr'
,
'Vcs-Hg'
]
def
_gen_outcomes
():
outcomes
=
{}
for
field
in
fields
:
for
isisnot
in
[
''
,
'-not'
]:
outcomes
[
'%s-is%s-present'
%
(
field
.
lower
(),
isisnot
)]
=
\
'The %s field is%s present in debian/control'
%
(
field
,
isisnot
.
replace
(
'-'
,
' '
))
return
outcomes
class
ControlFieldsPlugin
(
BasePlugin
):
class
ControlFieldsPlugin
(
BasePlugin
):
def
test_control_fields
(
self
):
def
test_control_fields
(
self
):
...
@@ -69,15 +65,21 @@ class ControlFieldsPlugin(BasePlugin):
...
@@ -69,15 +65,21 @@ class ControlFieldsPlugin(BasePlugin):
log
.
critical
(
'Could not open dsc file; skipping plugin'
)
log
.
critical
(
'Could not open dsc file; skipping plugin'
)
return
return
data
=
{}
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
outcome
=
"No Homepage field present"
for
item
in
fields
:
for
item
in
fields
:
if
item
in
dsc
:
if
item
in
dsc
:
self
.
info
(
'%s-is-present'
%
item
.
lower
(),
'%s: %s'
%
(
item
,
dsc
[
item
]))
data
[
item
]
=
dsc
[
item
]
log
.
debug
(
'%s: %s'
%
(
item
,
dsc
[
item
]))
if
"Homepage"
in
data
:
severity
=
constants
.
PLUGIN_SEVERITY_INFO
if
len
(
data
)
>
1
:
outcome
=
"Homepage and VCS control fields present"
else
:
else
:
# don't display missing VCS fields
outcome
=
"Homepage control field present"
#self.info('%s-is-not-present' % item.lower(), None)
log
.
debug
(
'%s field is not present'
%
item
)
plugin
=
ControlFieldsPlugin
self
.
failed
(
outcome
,
data
,
severity
)
outcomes
=
_gen_outcomes
()
plugin
=
ControlFieldsPlugin
debexpo/templates/plugins/controlfields/html.mako
0 → 100644
View file @
453b4b8d
<div class="qa-header">
${str(o.outcome)}
</div>
%if o.rich_data:
<div class="qa-content">
<dl>
%for field, contents in sorted(o.rich_data.items()):
<dt>${field}</dt>
<dd><a href="${contents}">${contents}</a></dt>
%endfor
</dl>
</div>
%endif
debexpo/templates/plugins/controlfields/text.mako
0 → 100644
View file @
453b4b8d
%for field, contents in sorted(o.rich_data.items()):
${field}: ${contents}
%endfor
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