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
c2ac6866
Commit
c2ac6866
authored
Aug 16, 2012
by
Clément Schreiner
Browse files
Update the maintaineremail plugin.
Not yet tested, but should be nearly complete.
parent
71c3d660
Changes
2
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/maintaineremail.py
View file @
c2ac6866
...
...
@@ -6,6 +6,7 @@
#
# Copyright © 2008 Jonny Lamb <jonny@debian.org>
# Copyright © 2012 Nicolas Dandrimont <Nicolas.Dandrimont@crans.org>
# Copyright © 2012 Clément Schreiner <clement@mux.me>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
...
...
@@ -36,6 +37,7 @@ __author__ = 'Jonny Lamb'
__copyright__
=
', '
.
join
([
'Copyright © 2008 Jonny Lamb'
,
'Copyright © 2012 Nicolas Dandrimont'
,
'Copyright © 2012 Clément Schreiner'
,
])
__license__
=
'MIT'
...
...
@@ -46,55 +48,90 @@ import re
from
debian
import
deb822
from
debexpo.lib
import
constants
from
debexpo.plugins
import
BasePlugin
from
debexpo.model
import
meta
from
debexpo.plugins.api
import
*
from
debexpo.model.users
import
User
log
=
logging
.
getLogger
(
__name__
)
class
MaintainerEmailPlugin
(
BasePlugin
):
@
test_result
class
MaintainerEmailTest
(
PluginResult
):
""" Result of the maintaineremail QA test. """
user_is_maintainer
=
bool_field
(
'user_is_maintainer'
)
user_in_uploaders
=
bool_field
(
'user_in_uploaders'
)
def
__str__
(
self
):
if
self
.
user_is_maintainer
:
return
'"Maintainer" email is the same as the uploader'
elif
self
.
user_in_uploaders
:
return
'The uploader is in the package
\'
s "Uploaders" field'
else
:
return
'The uploader is not in the package
\'
s "Maintainer"'
\
' or "Uploaders" fields'
class
UploaderEmail
(
PluginResult
):
""" Email address of one of the package's co-maintainers """
def
__str__
(
self
):
return
self
[
'email'
]
class
MaintainerEmailPlugin
(
QAPlugin
):
@
importercmd
def
test_maintainer_email
(
self
):
"""
Tests whether the maintainer email is the same as the uploader email.
"""
if
self
.
user_id
is
not
None
:
log
.
debug
(
'Checking whether the maintainer email is the same as the uploader email'
)
user
=
meta
.
session
.
query
(
User
).
get
(
self
.
user_id
)
if
user
is
not
None
:
maintainer_name
,
maintainer_email
=
email
.
utils
.
parseaddr
(
self
.
changes
[
'Maintainer'
])
uploader_emails
=
[]
dsc
=
deb822
.
Dsc
(
file
(
self
.
changes
.
get_dsc
()))
if
'Uploaders'
in
dsc
:
for
uploader_name
,
uploader_email
in
email
.
utils
.
getaddresses
([
dsc
[
'Uploaders'
]]):
uploader_emails
.
append
(
uploader_email
)
severity
=
constants
.
PLUGIN_SEVERITY_INFO
if
user
.
email
==
maintainer_email
:
log
.
debug
(
'"Maintainer" email is the same as the uploader'
)
outcome
=
'"Maintainer" email is the same as the uploader'
elif
user
.
email
in
uploader_emails
:
log
.
debug
(
'The uploader is in the package
\'
s "Uploaders" field'
)
outcome
=
'The uploader is in the package
\'
s "Uploaders" field'
else
:
log
.
warning
(
'%s != %s'
%
(
user
.
email
,
maintainer_email
))
outcome
=
'The uploader is not in the package
\'
s "Maintainer" or "Uploaders" fields'
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
data
=
{
'user-is-maintainer'
:
(
severity
==
constants
.
PLUGIN_SEVERITY_INFO
),
'user-email'
:
user
.
email
,
'maintainer-email'
:
maintainer_email
,
'uploader-emails'
:
uploader_emails
,
}
self
.
failed
(
outcome
,
data
,
severity
)
else
:
user_id
=
self
.
kw
.
get
(
'user_id'
,
None
)
if
user_id
is
None
:
log
.
warning
(
'Could not get the uploader
\'
s user details from the database'
)
return
log
.
debug
(
'Checking whether the maintainer email is the same as the uploader email'
)
user
=
self
.
session
.
query
(
User
).
get
(
user_id
)
log
.
debug
(
'Checking whether the maintainer email is the same as'
' the uploader email'
)
user
=
self
.
package_version
.
package
.
user
if
user
is
not
None
:
maintainer_name
,
maintainer_email
=
email
.
utils
.
parseaddr
(
self
.
changes
[
'Maintainer'
])
uploader_emails
=
[]
dsc
=
deb822
.
Dsc
(
file
(
self
.
changes
.
get_dsc
()))
if
'Uploaders'
in
dsc
:
for
uploader_name
,
uploader_email
in
email
.
utils
.
getaddresses
(
[
dsc
[
'Uploaders'
]]):
uploader_emails
.
append
(
uploader_email
)
severity
=
constants
.
PLUGIN_SEVERITY_INFO
user_is_maintainer
=
True
if
user
.
email
==
maintainer_email
:
log
.
debug
(
'"Maintainer" email is the same as the uploader'
)
elif
user
.
email
in
uploader_emails
:
user_in_uploaders
=
True
log
.
debug
(
'The uploader is in the package
\'
s "Uploaders" field'
)
else
:
log
.
warning
(
'%s != %s'
%
(
user
.
email
,
maintainer_email
))
severity
=
constants
.
PLUGIN_SEVERITY_WARNING
user_is_maintainer
=
False
result
=
self
.
new_test_result
(
severity
=
severity
,
user_is_maintainer
=
user_is_maintainer
,
user_email
=
user
.
email
,
maintainer_email
=
maintainer_email
)
for
uploader
in
uploaders_emails
:
self
.
new_result
(
UploaderEmail
,
email
=
'uploader'
)
plugin
=
MaintainerEmailPlugin
models
=
[
MaintainerEmailTest
,
UploaderEmail
,
]
debexpo/templates/plugins/maintaineremail/html.mako
View file @
c2ac6866
<div class="qa-header">
${
o.outcome
}
${
test_result
}
</div>
%if not
o.rich_data["
user
-
is
-
maintainer
"]
:
%if not
test_resut.
user
_
is
_
maintainer:
<div class="qa-content">
<dl>
<dt>User email</dt>
<dd><a href="mailto:${
o.rich_data["
user-email
"
]}">${
o.rich_data["
user-email
"
]}</a></dd>
<dd><a href="mailto:${
test_result['
user-email
'
]}">${
test_result['
user-email
'
]}</a></dd>
<dt>"Maintainer" email</dt>
<dd><a href="mailto:${
o.rich_data["
maintainer-email
"
]}">${
o.rich_data["
maintainer-email
"
]}</a></dd>
%
if o.rich_data["uploader-emails"]:
<dd><a href="mailto:${
test_result['
maintainer-email
'
]}">${
test_result['
maintainer-email
'
]}</a></dd>
%
<dt>"Uploaders" emails</dt>
<dd>
<ul>
%for email in
o.rich_data["
uploader
-
email
s"
]:
%for email in
results['
uploader
_
email
'
]:
<li><a href="mailto:${email}">${email}</a></li>
%endfor
</ul>
...
...
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