~launchpad-pqm/launchpad/devel

8687.15.11 by Karl Fogel
Add the copyright header block to files under lib/lp/answers/.
1
# Copyright 2009 Canonical Ltd.  This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
3691.398.13 by Francis J. Lacoste
Rename answer tracker py and ZCML files.
3
4
"""Adapters used in the Answer Tracker."""
3691.254.21 by Francis J. Lacoste
Add adapter from ITicket to ITicketTarget.
5
6
__metaclass__ = type
3791.1.1 by Francis J. Lacoste
Add an adapter from IDistroRelease to ITicketTarget.
7
__all__ = []
3691.254.21 by Francis J. Lacoste
Add adapter from ITicket to ITicketTarget.
8
4319.2.29 by Francis J. Lacoste
Rename components.question to component.answertracker
9
10409.5.55 by Curtis Hovey
Removed glob imports from answers.
10
from lp.answers.interfaces.faqtarget import IFAQTarget
4319.2.39 by Francis J. Lacoste
Add an adapter to IFAQTarget to IQuestion.
11
12
3691.398.13 by Francis J. Lacoste
Rename answer tracker py and ZCML files.
13
def question_to_questiontarget(question):
14
    """Adapts an IQuestion to its IQuestionTarget."""
15
    return question.target
16
17
4285.2.5 by Mark Shuttleworth
Test fixes for renamed series
18
def series_to_questiontarget(series):
19
    """Adapts an IDistroSeries or IProductSeries into an IQuestionTarget."""
20
    return series.parent
3851.5.4 by Francis J. Lacoste
Add adapter from ISourcePackageRelease to IQuestionTarget.
21
4319.2.31 by Francis J. Lacoste
Add adapter for IDistributionSourcePackage to IFAQTarget.
22
3851.5.4 by Francis J. Lacoste
Add adapter from ISourcePackageRelease to IQuestionTarget.
23
def sourcepackagerelease_to_questiontarget(sourcepackagerelease):
24
    """Adapts an ISourcePackageRelease into an IQuestionTarget."""
4285.2.5 by Mark Shuttleworth
Test fixes for renamed series
25
    return sourcepackagerelease.distrosourcepackage
4319.2.31 by Francis J. Lacoste
Add adapter for IDistributionSourcePackage to IFAQTarget.
26
27
13014.2.4 by Curtis Hovey
Added sourcepackage_to_questiontarget to preserve code that is working with
28
def sourcepackage_to_questiontarget(sourcepackage):
29
    """Adapts an ISourcePackage into an IQuestionTarget."""
30
    return sourcepackage.distribution_sourcepackage
31
32
4319.2.39 by Francis J. Lacoste
Add an adapter to IFAQTarget to IQuestion.
33
def question_to_faqtarget(question):
34
    """Adapt an IQuestion into an IFAQTarget.
35
36
    It adapts the question's target to IFAQTarget.
37
    """
38
    return IFAQTarget(question.target)
39
40
4319.2.31 by Francis J. Lacoste
Add adapter for IDistributionSourcePackage to IFAQTarget.
41
def distrosourcepackage_to_faqtarget(distrosourcepackage):
42
    """Adapts an `IDistributionSourcePackage` into an `IFAQTarget`."""
43
    return distrosourcepackage.distribution
4319.2.47 by Francis J. Lacoste
Add adapter from ISourcePackage to IFAQTarget.
44
45
46
def sourcepackage_to_faqtarget(sourcepackage):
47
    """Adapts an `ISourcePackage` into an `IFAQTarget`."""
4319.2.51 by Francis J. Lacoste
Typos.
48
    return sourcepackage.distribution
4319.7.2 by Francis J. Lacoste
Add adapter from IFAQ to IFAQTarget.
49
50
51
def faq_to_faqtarget(faq):
52
    """Adapts an `IFAQ` into an `IFAQTarget`."""
53
    return faq.target