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
405ae114
Commit
405ae114
authored
Jul 13, 2012
by
Clément Schreiner
Browse files
Actually import tags from heuristics into the database. Finally.
parent
f87e66ea
Changes
1
Hide whitespace changes
Inline
Side-by-side
debexpo/plugins/debtags.py
View file @
405ae114
...
...
@@ -37,6 +37,9 @@ __copyright__ = 'Copyright © 2012 Clément Schreiner'
__license__
=
'MIT'
from
debexpo.model.plugin_results
import
PluginResult
,
plugin_result_mapper
from
debexpo.model.binary_packages
import
BinaryPackage
from
debexpo.model
import
meta
from
debexpo.plugins
import
BasePlugin
from
debexpo.lib.debtagsd.debdata
import
autotag
,
datasources
,
utils
from
debexpo.lib.repository
import
Repository
...
...
@@ -46,6 +49,7 @@ import pylons
import
urllib2
from
debian
import
debtags
import
re
import
logging
...
...
@@ -77,21 +81,40 @@ class DebtagsPlugin(BasePlugin):
log
.
debug
(
'Getting the tags from debtags database'
)
db
=
debtags
.
DB
()
db
.
read
(
open
(
'/var/lib/debtags/package-tags'
,
'r'
))
return
db
.
tags_of_package
(
self
.
package_version
.
package
.
name
)
tags
=
{}
for
pkg
in
self
.
binary_packages
:
tags
[
pkg
.
name
]
=
db
.
tags_of_package
(
pkg
.
name
)
return
tags
def
run
(
self
):
"""
Apply
debtags
' heuristics to
the package.
Get
debtags
for
the package.
"""
q
=
meta
.
session
.
query
(
BinaryPackage
)
q
=
q
.
filter_by
(
package_version_id
=
self
.
package_version
.
id
)
self
.
binary_packages
=
q
.
all
()
if
self
.
_package_in_debian
:
for
tag
in
self
.
_tags_from_db
:
self
.
_new_result
(
Debtag
,
tag
=
tag
,
source
=
'debtags'
)
for
pkg
in
self
.
binary_packages
:
for
tag
in
self
.
_tags_from_db
[
pkg
.
name
]:
self
.
_new_result
(
Debtag
,
tag
=
tag
,
source
=
'debtags'
,
package
=
pkg
)
log
.
debug
(
'Applying debtags heuristics to the package'
)
self
.
tags
=
set
()
autotag
=
Autodebtag
(
BinPackages
)
autotag
.
load_sources
(
self
.
binary_packages
)
tags
=
autotag
.
get_tags
()
for
pkg
in
tags
:
for
tag
in
tags
[
pkg
]:
self
.
_new_result
(
Debtag
,
tag
=
tag
,
source
=
'autotag'
,
package
=
pkg
)
class
Autodebtag
(
autotag
.
Autodebtag
):
"""
Use debtagsd's heuristics to assign debtags to a new package
...
...
@@ -165,9 +188,9 @@ class BinPackages(datasources.DataSource):
sdesc
,
ldesc
,
[
p
.
arch
],
mv
(
'Pre-Depends'
),
# deps
mv
(
'Depends'
),
# recommends
mv
(
'Recommends'
),
# suggests
mv
(
'Pre-Depends'
),
mv
(
'Depends'
),
mv
(
'Recommends'
),
mv
(
'Suggests'
),
mv
(
'Enhances'
),
p
.
package_version
.
distribution
)
...
...
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