コード例 #1
0
class ISnapBaseSet(ISnapBaseSetEdit):
    """Interface representing the set of bases for snaps."""

    export_as_webservice_collection(ISnapBase)

    def __iter__():
        """Iterate over `ISnapBase`s."""

    def __getitem__(name):
        """Return the `ISnapBase` with this name."""

    @operation_parameters(name=TextLine(title=_("Base name"), required=True))
    @operation_returns_entry(ISnapBase)
    @export_read_operation()
    @operation_for_version("devel")
    def getByName(name):
        """Return the `ISnapBase` with this name.

        :raises NoSuchSnapBase: if no base exists with this name.
        """

    @operation_returns_entry(ISnapBase)
    @export_read_operation()
    @operation_for_version("devel")
    def getDefault():
        """Get the default base.

        This will be used to pick the default distro series for snaps that
        do not specify a base.
        """

    @collection_default_content()
    def getAll():
        """Return all `ISnapBase`s."""
コード例 #2
0
class ITranslationGroupSet(Interface):
    """A container for translation groups."""

    export_as_webservice_collection(ITranslationGroup)

    title = Attribute('Title')

    @operation_parameters(
        name=TextLine(title=_("Name of the translation group"),))
    @operation_returns_entry(ITranslationGroup)
    @export_read_operation()
    @operation_for_version('devel')
    def getByName(name):
        """Get a translation group by name."""

    def __getitem__(name):
        """Get a translation group by name."""

    @collection_default_content()
    def _get():
        """Return a collection of all entries."""

    def __iter__():
        """Iterate through the translation groups in this set."""

    def new(name, title, summary, translation_guide_url, owner):
        """Create a new translation group."""

    def getByPerson(person):
        """Return the translation groups which that person is a member of."""

    def getGroupsCount():
        """Return the amount of translation groups available."""
コード例 #3
0
ファイル: country.py プロジェクト: pombreda/UnnaturalCodeFork
class ICountrySet(Interface):
    """A container for countries."""
    export_as_webservice_collection(ICountry)

    def __getitem__(key):
        """Get a country."""

    def __iter__():
        """Iterate through the countries in this set."""

    @operation_parameters(name=TextLine(title=_("Name"), required=True))
    @operation_returns_entry(ICountry)
    @export_read_operation()
    def getByName(name):
        """Return a country by its name."""

    @operation_parameters(code=TextLine(title=_("Code"), required=True))
    @operation_returns_entry(ICountry)
    @export_read_operation()
    def getByCode(code):
        """Return a country by its code."""

    @collection_default_content()
    def getCountries():
        """Return a collection of countries."""
コード例 #4
0
class ISnappySeriesSet(ISnappySeriesSetEdit):
    """Interface representing the set of snappy series."""

    export_as_webservice_collection(ISnappySeries)

    def __iter__():
        """Iterate over `ISnappySeries`."""

    def __getitem__(name):
        """Return the `ISnappySeries` with this name."""

    @operation_parameters(name=TextLine(title=_("Snappy series name"),
                                        required=True))
    @operation_returns_entry(ISnappySeries)
    @export_read_operation()
    @operation_for_version("devel")
    def getByName(name):
        """Return the `ISnappySeries` with this name.

        :raises NoSuchSnappySeries: if no snappy series exists with this name.
        """

    @collection_default_content()
    def getAll():
        """Return all `ISnappySeries`."""
コード例 #5
0
class IProcessorSet(Interface):
    """Operations related to Processor instances."""
    export_as_webservice_collection(IProcessor)

    @operation_parameters(
        name=TextLine(required=True))
    @operation_returns_entry(IProcessor)
    @export_read_operation()
    @operation_for_version('devel')
    def getByName(name):
        """Return the IProcessor instance with the matching name.

        :param name: The name to look for.
        :raise ProcessorNotFound: if there is no processor with that name.
        :return: A `IProcessor` instance if found
        """

    @collection_default_content()
    def getAll():
        """Return all the `IProcessor` known to Launchpad."""

    def getRestricted():
        """Return all restricted `IProcessor`s."""

    def new(name, title, description, restricted):
        """Create a new processor.
コード例 #6
0
ファイル: cve.py プロジェクト: pombreda/UnnaturalCodeFork
class ICveSet(Interface):
    """The set of ICve objects."""

    export_as_webservice_collection(ICve)

    title = Attribute('Title')

    def __getitem__(key):
        """Get a Cve by sequence number."""

    def __iter__():
        """Iterate through all the Cve records."""

    def new(sequence, description, cvestate=CveStatus.CANDIDATE):
        """Create a new ICve."""

    @collection_default_content()
    def getAll():
        """Return all ICVEs"""

    def latest(quantity=5):
        """Return the most recently created CVE's, newest first, up to the
        number given in quantity."""

    def latest_modified(quantity=5):
        """Return the most recently modified CVE's, newest first, up to the
        number given in quantity."""

    def search(text):
        """Search the CVE database for matching CVE entries."""

    def inText(text):
        """Find one or more Cve's by analysing the given text.

        This will look for references to CVE or CAN numbers, and return the
        CVE references. It will create any CVE's that it sees which are
        already not in the database. It returns the list of all the CVE's it
        found in the text.
        """

    def inMessage(msg):
        """Find any CVE's in the given message.

        This will create any CVE's that it does not already know about. It
        returns a list of all the CVE's that it saw mentioned in the
        message.
        """

    def getBugCvesForBugTasks(bugtasks, cve_mapper=None):
        """Return (Bug, Cve) tuples that correspond to the supplied bugtasks.

        Returns an iterable of (Bug, Cve) tuples for bugs related to the
        supplied sequence of bugtasks.

        If a function cve_mapper is specified, a sequence of tuples
        (bug, cve_mapper(cve)) is returned.
        """

    def getBugCveCount():
        """Return the number of CVE bug links there is in Launchpad."""
コード例 #7
0
class IProjectGroupSet(Interface):
    """The collection of projects."""

    export_as_webservice_collection(IProjectGroup)

    title = Attribute('Title')

    def __iter__():
        """Return an iterator over all the projects."""

    def __getitem__(name):
        """Get a project by its name."""

    def get(projectid):
        """Get a project by its id.

        If the project can't be found a NotFoundError will be raised.
        """

    def getByName(name, ignore_inactive=False):
        """Return the project with the given name, ignoring inactive projects
        if ignore_inactive is True.

        Return the default value if there is no such project.
        """

    def new(name,
            displayname,
            title,
            homepageurl,
            summary,
            description,
            owner,
            mugshot=None,
            logo=None,
            icon=None,
            registrant=None):
        """Create and return a project with the given arguments.

        For a description of the parameters see `IProjectGroup`.
        """

    def count_all():
        """Return the total number of projects registered in Launchpad."""

    @collection_default_content()
    @operation_parameters(text=TextLine(title=_("Search text")))
    @operation_returns_collection_of(IProjectGroup)
    @export_read_operation()
    def search(text=None, search_products=False):
        """Search through the Registry database for projects that match the
        query terms. text is a piece of text in the title / summary /
        description fields of project (and possibly product). soyuz,
        bazaar, malone etc are hints as to whether the search should
        be limited to projects that are active in those Launchpad
        applications."""

    def forReview():
        """Return a list of ProjectGroups which need review, or which have
コード例 #8
0
class IDistributionSet(Interface):
    """Interface for DistrosSet"""
    export_as_webservice_collection(IDistribution)

    title = Attribute('Title')

    def __iter__():
        """Iterate over all distributions.

        Ubuntu and its flavours will always be at the top of the list, with
        the other ones sorted alphabetically after them.
        """

    def __getitem__(name):
        """Retrieve a distribution by name"""

    @collection_default_content()
    def getDistros():
        """Return all distributions.

        Ubuntu and its flavours will always be at the top of the list, with
        the other ones sorted alphabetically after them.
        """

    def count():
        """Return the number of distributions in the system."""

    def get(distributionid):
        """Return the IDistribution with the given distributionid."""

    def getByName(distroname):
        """Return the IDistribution with the given name or None."""

    def new(name,
            display_name,
            title,
            description,
            summary,
            domainname,
            members,
            owner,
            registrant,
            mugshot=None,
            logo=None,
            icon=None):
        """Create a new distribution."""

    def getCurrentSourceReleases(distro_to_source_packagenames):
        """Lookup many distribution source package releases.

        :param distro_to_source_packagenames: A dictionary with
            its keys being `IDistribution` and its values a list of
            `ISourcePackageName`.
        :return: A dict as per `IDistribution.getCurrentSourceReleases`
        """

    def getDerivedDistributions():
        """Find derived distributions.
コード例 #9
0
ファイル: malone.py プロジェクト: pombreda/UnnaturalCodeFork
class IMaloneApplication(ILaunchpadApplication):
    """Application root for malone."""
    export_as_webservice_collection(IBug)

    def searchTasks(search_params):
        """Search IBugTasks with the given search parameters."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(bug_id=copy_field(IBug['id']),
                          related_bug=Reference(schema=IBug))
    @export_read_operation()
    @operation_for_version('devel')
    def getBugData(user, bug_id, related_bug=None):
        """Search bugtasks matching the specified criteria.

        The only criteria currently supported is to search for a bugtask with
        the specified bug id.

        :return: a list of matching bugs represented as json data
        """

    bug_count = Attribute("The number of bugs recorded in Launchpad")
    bugwatch_count = Attribute("The number of links to external bug trackers")
    bugtask_count = Attribute("The number of bug tasks in Launchpad")
    projects_with_bugs_count = Attribute(
        "The number of products and "
        "distributions which have bugs in Launchpad.")
    shared_bug_count = Attribute("The number of bugs that span multiple "
                                 "products and distributions")
    bugtracker_count = Attribute("The number of bug trackers in Launchpad")
    top_bugtrackers = Attribute("The BugTrackers with the most watches.")

    @collection_default_content()
    def empty_list():
        """Return an empty set - only exists to keep lazr.restful happy."""

    @call_with(owner=REQUEST_USER)
    @operation_parameters(target=Reference(
        schema=IBugTarget,
        required=True,
        title=u"The project, distribution or source package that has "
        "this bug."))
    @export_factory_operation(IBug, [
        'title', 'description', 'tags', 'information_type', 'security_related',
        'private'
    ])
    def createBug(owner,
                  title,
                  description,
                  target,
                  information_type=None,
                  tags=None,
                  security_related=None,
                  private=None):
        """Create a bug (with an appropriate bugtask) and return it.
コード例 #10
0
class IQuestionSet(IQuestionCollection):
    """A utility that contain all the questions published in Launchpad."""

    export_as_webservice_collection(Interface)

    title = Attribute('Title')

    @operation_parameters(question_id=Int(
        title=_('The id of the question to get'), required=True))
    @operation_returns_entry(Interface)
    @export_read_operation()
    @export_operation_as("getByID")
    @operation_for_version('devel')
    def get(question_id, default=None):
        """Return the question with the given id.

        Return :default: if no such question exists.
        """

    def findExpiredQuestions(days_before_expiration):
        """Return the questions that are expired.

        Return all the questions in the Open or Needs information state,
        without an assignee or bug links, that did not receive any new
        comments in the last <days_before_expiration> days.
        """

    @collection_default_content(limit=5)
    def getMostActiveProjects(limit=5):
        """Return the list of projects that asked the most questions in
        the last 60 days.

        It should only return projects that officially uses the Answer
        Tracker.

        :param limit: The number of projects to return.
        """

    def getOpenQuestionCountByPackages(packages):
        """Return number of open questions for the list of packages.
コード例 #11
0
class ILiveFSSet(Interface):
    """A utility to create and access live filesystems."""

    export_as_webservice_collection(ILiveFS)

    @call_with(registrant=REQUEST_USER)
    @export_factory_operation(
        ILiveFS, ["owner", "distro_series", "name", "metadata"])
    @operation_for_version("devel")
    def new(registrant, owner, distro_series, name, metadata,
            require_virtualized=True, date_created=None):
        """Create an `ILiveFS`."""

    def exists(owner, distro_series, name):
        """Check to see if a matching live filesystem exists."""

    @operation_parameters(
        owner=Reference(IPerson, title=_("Owner"), required=True),
        distro_series=Reference(
            IDistroSeries, title=_("Distroseries"), required=True),
        name=TextLine(title=_("Live filesystem name"), required=True))
    @operation_returns_entry(ILiveFS)
    @export_read_operation()
    @operation_for_version("devel")
    def getByName(owner, distro_series, name):
        """Return the appropriate `ILiveFS` for the given objects."""

    def interpret(owner_name, distribution_name, distro_series_name, name):
        """Like `getByName`, but takes names of objects."""

    def getByPerson(owner):
        """Return all live filesystems with the given `owner`."""

    @collection_default_content()
    def getAll():
        """Return all of the live filesystems in Launchpad.
コード例 #12
0
ファイル: product.py プロジェクト: pombredanne/launchpad-3
class IProductSet(Interface):
    export_as_webservice_collection(IProduct)

    title = Attribute("The set of Products registered in the Launchpad")

    people = Attribute(
        "The PersonSet, placed here so we can easily render "
        "the list of latest teams to register on the /projects/ page.")

    def get_users_private_products(user):
        """Get users non-public products.

        :param user: Which user are we searching products for.
        :return: An iterable of IProduct
        """

    def get_all_active(eager_load=True):
        """Get all active products.

        :param eager_load: If False do not load related objects such as the
            owner.
        :return: An iterable of IProduct.
        """

    def __iter__():
        """Return an iterator over all the active products."""

    def __getitem__(name):
        """Get a product by its name."""

    def get(productid):
        """Get a product by its id.

        If the product can't be found a NotFoundError will be
        raised.
        """

    def getByName(name, ignore_inactive=False):
        """Return the product with the given name, ignoring inactive products
        if ignore_inactive is True.

        Return None if there is no such product.
        """

    def getProductsWithBranches(num_products=None):
        """Return an iterator over all active products that have branches.

        If num_products is not None, then the first `num_products` are
        returned.
        """

    @call_with(owner=REQUEST_USER)
    @rename_parameters_as(
        projectgroup='project_group',
        homepageurl='home_page_url', screenshotsurl='screenshots_url',
        freshmeatproject='freshmeat_project', wikiurl='wiki_url',
        downloadurl='download_url',
        sourceforgeproject='sourceforge_project',
        programminglang='programming_lang')
    @export_factory_operation(
        IProduct, ['name', 'display_name', 'title', 'summary', 'description',
                   'projectgroup', 'homepageurl', 'screenshotsurl',
                   'downloadurl', 'freshmeatproject', 'wikiurl',
                   'sourceforgeproject', 'programminglang',
                   'project_reviewed', 'licenses', 'license_info',
                   'registrant', 'bug_supervisor', 'driver'])
    @export_operation_as('new_project')
    def createProduct(owner, name, display_name, title, summary,
                      description=None, projectgroup=None, homepageurl=None,
                      screenshotsurl=None, wikiurl=None,
                      downloadurl=None, freshmeatproject=None,
                      sourceforgeproject=None, programminglang=None,
                      project_reviewed=False, mugshot=None, logo=None,
                      icon=None, licenses=None, license_info=None,
                      registrant=None, bug_supervisor=None, driver=None):
        """Create and return a brand new Product.

        See `IProduct` for a description of the parameters.
        """

    @operation_parameters(
        search_text=TextLine(title=_("Search text")),
        active=Bool(title=_("Is the project active")),
        project_reviewed=Bool(title=_("Is the project licence reviewed")),
        licenses=Set(title=_('Licenses'),
                       value_type=Choice(vocabulary=License)),
        created_after=Date(title=_("Created after date")),
        created_before=Date(title=_("Created before date")),
        has_subscription=Bool(title=_("Has a commercial subscription")),
        subscription_expires_after=Date(
            title=_("Subscription expires after")),
        subscription_expires_before=Date(
            title=_("Subscription expired before")),
        subscription_modified_after=Date(
            title=_("Subscription modified after")),
        subscription_modified_before=Date(
            title=_("Subscription modified before")))
    @operation_returns_collection_of(IProduct)
    @export_read_operation()
    @export_operation_as('licensing_search')
    @call_with(user=REQUEST_USER)
    def forReview(user,
                  search_text=None,
                  active=None,
                  project_reviewed=None,
                  licenses=None,
                  created_after=None,
                  created_before=None,
                  has_subscription=None,
                  subscription_expires_after=None,
                  subscription_expires_before=None,
                  subscription_modified_after=None,
                  subscription_modified_before=None):
        """Return an iterator over products that need to be reviewed."""

    @collection_default_content()
    def _request_user_search():
        """Wrapper for search to use request user in default content."""

    @call_with(user=REQUEST_USER)
    @operation_parameters(text=TextLine(title=_("Search text")))
    @operation_returns_collection_of(IProduct)
    @export_read_operation()
    def search(user, text=None):
        """Search through the Registry database for products that match the
        query terms. text is a piece of text in the title / summary /
        description fields of product.

        This call eager loads data appropriate for web API; caution may be
        needed for other callers.
        """

    @operation_returns_collection_of(IProduct)
    @call_with(user=REQUEST_USER, quantity=None)
    @export_read_operation()
    def latest(user, quantity=5):
        """Return the latest projects registered in Launchpad.

        The supplied user determines which objects are visible.

        If the quantity is not specified or is a value that is not 'None'
        then the set of projects returned is limited to that value (the
        default quantity is 5).  If quantity is 'None' then all projects are
        returned.  For the web service it is not possible to specify the
        quantity, so all projects are returned, latest first.
        """

    def getTranslatables():
        """Return an iterator over products that have translatable resources.

        Skips products that are not configured to be translated in
        Launchpad, as well as non-active ones.
        """

    def count_all():
        """Return a count of the total number of products registered in
        Launchpad."""

    def count_translatable():
        """Return a count of the number of products that have
        upstream-oriented translations configured in Rosetta."""

    def count_buggy():
        """Return the number of products that have bugs associated with them
        in Launchpad."""

    def count_featureful():
        """Return the number of products that have specs associated with
        them in Blueprint."""

    def count_reviewed():
        """Return a count of the number of products in the Launchpad that
        are both active and reviewed."""

    def count_answered():
        """Return the number of projects that have questions and answers
        associated with them.
        """

    def count_codified():
        """Return the number of projects that have branches associated with
        them.
        """

    def getProductsWithNoneRemoteProduct(bugtracker_type=None):
        """Get all the IProducts having a `remote_product` of None

        The result can be filtered to only return Products associated
        with a given bugtracker type.
        """

    def getSFLinkedProductsWithNoneRemoteProduct():
        """Get IProducts with a sourceforge project and no remote_product."""
コード例 #13
0
class IBuilderSet(IBuilderSetAdmin):
    """Collections of builders.

    IBuilderSet provides access to all Builders in the system,
    and also acts as a Factory to allow the creation of new Builders.
    Methods on this interface should deal with the set of Builders:
    methods that affect a single Builder should be on IBuilder.
    """
    export_as_webservice_collection(IBuilder)
    title = Attribute('Title')

    def __iter__():
        """Iterate over builders."""

    def __getitem__(name):
        """Retrieve a builder by name"""

    @operation_parameters(name=TextLine(title=_("Builder name"),
                                        required=True))
    @operation_returns_entry(IBuilder)
    @export_read_operation()
    def getByName(name):
        """Retrieve a builder by name"""

    def count():
        """Return the number of builders in the system."""

    def get(builder_id):
        """Return the IBuilder with the given builderid."""

    @collection_default_content()
    def getBuilders():
        """Return all active configured builders."""

    @export_read_operation()
    @operation_for_version('devel')
    def getBuildQueueSizes():
        """Return the number of pending builds for each processor.

        :return: a dict of tuples with the queue size and duration for
            each processor and virtualisation. For example::

                {
                    'virt': {
                                '386': (1, datetime.timedelta(0, 60)),
                                'amd64': (2, datetime.timedelta(0, 30)),
                            },
                    'nonvirt':...
                }

            The tuple contains the size of the queue, as an integer,
            and the sum of the jobs 'estimated_duration' in queue,
            as a timedelta or None for empty queues.
        """

    @operation_parameters(processor=Reference(title=_("Processor"),
                                              required=True,
                                              schema=IProcessor),
                          virtualized=Bool(title=_("Virtualized"),
                                           required=False,
                                           default=True))
    @operation_returns_collection_of(IBuilder)
    @export_read_operation()
    @operation_for_version('devel')
    def getBuildersForQueue(processor, virtualized):
        """Return all builders for given processor/virtualization setting."""
コード例 #14
0
class IPackagesetSet(IPackagesetSetEdit):
    """An interface for multiple package sets."""
    export_as_webservice_collection(IPackageset)

    @operation_parameters(
        name=TextLine(title=_('Package set name'), required=True),
        distroseries=Reference(
            IDistroSeries,
            title=_("Distroseries"),
            required=False,
            readonly=True,
            description=_("The distribution series to which the packageset "
                          "is related.")))
    @operation_returns_entry(IPackageset)
    @export_read_operation()
    def getByName(name, distroseries=None):
        """Return the single package set with the given name (if any).

        :param name: the name of the package set sought.
        :param distroseries: the distroseries to which the new packageset
            is related. Defaults to the current Ubuntu series.

        :return: An `IPackageset` instance.
        :raise NoSuchPackageSet: if no package set is found.
        """

    @collection_default_content()
    def get():
        """Return all of the package sets in Launchpad.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    def getByOwner(owner):
        """Return the package sets belonging to the given owner (if any).

        :param owner: the owner of the package sets sought.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    @operation_parameters(distroseries=copy_field(
        IPackageset['distroseries'],
        description=_("The distribution series to which the packagesets "
                      "are related.")))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    @operation_for_version("beta")
    def getBySeries(distroseries):
        """Return the package sets associated with the given distroseries.

        :param distroseries: A `DistroSeries`.

        :return: An iterable collection of `IPackageset` instances.
        """

    def getForPackages(distroseries, sourcepackagename_ids):
        """Get `Packagesets` that directly contain the given packages.

        :param distroseries: `DistroSeries` to look in.  Only packagesets for
            this series will be returned.
        :param sourcepackagename_ids: A sequence of `SourcePackageName` ids.
            Only packagesets for these package names will be returned.
        :return: A dict mapping `SourcePackageName` ids to lists of their
            respective packagesets, in no particular order.
        """

    @operation_parameters(sourcepackagename=TextLine(
        title=_('Source package name'), required=True),
                          distroseries=copy_field(IPackageset['distroseries'],
                                                  required=False),
                          direct_inclusion=Bool(required=False))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    def setsIncludingSource(sourcepackagename,
                            distroseries=None,
                            direct_inclusion=False):
        """Get the package sets that include this source package.

        Return all package sets that directly or indirectly include the
        given source package name.

        :param sourcepackagename: the included source package name; can be
            either a string or a `ISourcePackageName`.
        :param distroseries: the `IDistroSeries` in which to look for sets.
            If omitted, matching package sets from all series will be
            returned.
        :param direct_inclusion: if this flag is set to True, then only
            package sets that directly include this source package name will
            be considered.

        :raises NoSuchSourcePackageName: if a source package with the given
            name cannot be found.
        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    def __getitem__(name):
        """Retrieve a package set by name."""
コード例 #15
0
class ITranslationImportQueue(Interface):
    """A set of files to be imported into Rosetta."""
    export_as_webservice_collection(ITranslationImportQueueEntry)

    def __iter__():
        """Iterate over all entries in the queue."""

    def __getitem__(id):
        """Return the ITranslationImportQueueEntry with the given id.

        If there is not entries with that id, the NotFoundError exception is
        raised.
        """

    def countEntries():
        """Return the number of `TranslationImportQueueEntry` records."""

    def addOrUpdateEntry(path, content, by_maintainer, importer,
        sourcepackagename=None, distroseries=None, productseries=None,
        potemplate=None, pofile=None, format=None):
        """Return a new or updated entry of the import queue.

        :arg path: is the path, with the filename, of the uploaded file.
        :arg content: is the file content.
        :arg by_maintainer: indicates if the file was uploaded by the
            maintainer of the project or package.
        :arg importer: is the person that did the import.
        :arg sourcepackagename: is the link of this import with source
            package.
        :arg distroseries: is the link of this import with a distribution.
        :arg productseries: is the link of this import with a product branch.
        :arg potemplate: is the link of this import with an IPOTemplate.
        :arg pofile: is the link of this import with an IPOFile.
        :arg format: a TranslationFileFormat.
        :return: the entry, or None if processing failed.

        The entry is either for a sourcepackage or a productseries, so
        only one of them can be specified.
        """

    def addOrUpdateEntriesFromTarball(content, by_maintainer, importer,
        sourcepackagename=None, distroseries=None, productseries=None,
        potemplate=None, filename_filter=None, approver_factory=None,
        only_templates=False):
        """Add all .po or .pot files from the tarball at :content:.

        :arg content: is a tarball stream.
        :arg by_maintainer: indicates if the file was uploaded by the
            maintainer of the project or package.
        :arg importer: is the person that did the import.
        :arg sourcepackagename: is the link of this import with source
            package.
        :arg distroseries: is the link of this import with a distribution.
        :arg productseries: is the link of this import with a product branch.
        :arg potemplate: is the link of this import with an IPOTemplate.
        :arg approver_factory: is a factory that can be called to create an
            approver.  The method invokes the approver on any queue entries
            that it creates. If this is None, no approval is performed.
        :arg only_templates: Flag to indicate that only translation templates
            in the tarball should be used.
        :return: A tuple of the number of successfully processed files and a
            list of those filenames that could not be processed correctly.

        The entries are either for a sourcepackage or a productseries, so
        only one of them can be specified.
        """

    def get(id):
        """Return the ITranslationImportQueueEntry with the given id or None.
        """

    @collection_default_content()
    @operation_parameters(
        import_status=copy_field(ITranslationImportQueueEntry['status']))
    @operation_returns_collection_of(ITranslationImportQueueEntry)
    @export_read_operation()
    def getAllEntries(target=None, import_status=None, file_extensions=None):
        """Return all entries this import queue has.

        :arg target: IPerson, IProduct, IProductSeries, IDistribution,
            IDistroSeries or ISourcePackage the import entries are attached to
            or None to get all entries available.
        :arg import_status: RosettaImportStatus entry.
        :arg file_extensions: Sequence of filename suffixes to match, usually
            'po' or 'pot'.

        If any of target, status or file_extension are given, the returned
        entries are filtered based on those values.
        """

    @export_read_operation()
    @operation_parameters(target=Reference(schema=IHasTranslationImports))
    @operation_returns_entry(ITranslationImportQueueEntry)
    def getFirstEntryToImport(target=None):
        """Return the first entry of the queue ready to be imported.

        :param target: IPerson, IProduct, IProductSeries, IDistribution,
            IDistroSeries or ISourcePackage the import entries are attached to
            or None to get all entries available.
        """

    @export_read_operation()
    @operation_parameters(
        status=copy_field(ITranslationImportQueueEntry['status']))
    @operation_returns_collection_of(IHasTranslationImports)
    @call_with(user=REQUEST_USER)
    def getRequestTargets(user,  status=None):
        """List `Product`s and `DistroSeries` with pending imports.

        :arg status: Filter by `RosettaImportStatus`.

        All returned items will implement `IHasTranslationImports`.
        """

    def executeOptimisticApprovals(txn=None):
        """Try to approve Needs-Review entries.

        :arg txn: Optional transaction manager.  If given, will be
            committed regularly.

        This method moves all entries that we know where should they be
        imported from the Needs Review status to the Accepted one.
        """

    def executeOptimisticBlock(txn=None):
        """Try to move entries from the Needs Review status to Blocked one.

        :arg txn: Optional transaction manager.  If given, will be
            committed regularly.

        This method moves uploaded translations for Blocked templates to
        the Blocked status as well.  This lets you block a template plus
        all its present or future translations in one go.

        :return: The number of items blocked.
        """

    def cleanUpQueue():
        """Remove old entries in terminal states.

        This "garbage-collects" entries from the queue based on their
        status (e.g. Deleted and Imported ones) and how long they have
        been in that status.

        :return: The number of entries deleted.
        """

    def remove(entry):
        """Remove the given :entry: from the queue."""
コード例 #16
0
class ILanguageSet(Interface):
    """The collection of languages.

    The standard get method will return only the visible languages.
    If you want to access all languages known to Launchpad, use
    the getAllLanguages method.
    """

    export_as_webservice_collection(ILanguage)

    @export_read_operation()
    @operation_returns_collection_of(ILanguage)
    @call_with(want_translators_count=True)
    def getAllLanguages(want_translators_count=False):
        """Return a result set of all ILanguages from Launchpad."""

    @collection_default_content(want_translators_count=True)
    def getDefaultLanguages(want_translators_count=False):
        """An API wrapper for `common_languages`"""

    common_languages = Attribute(
        "An iterator over languages that are not hidden.")

    def __iter__():
        """Returns an iterator over all languages."""

    def __getitem__(code):
        """Return the language with the given code.

        If there is no language with the give code,
        raise NotFoundError exception.
        """

    def get(language_id):
        """Return the language with the given id."""

    def getLanguageByCode(code):
        """Return the language with the given code or None."""

    def keys():
        """Return an iterator over the language codes."""

    def canonicalise_language_code(code):
        """Convert a language code to standard xx_YY form."""

    def codes_to_languages(codes):
        """Convert a list of ISO language codes to language objects.

        Unrecognised language codes are ignored.
        """

    def createLanguage(code,
                       englishname,
                       nativename=None,
                       pluralforms=None,
                       pluralexpression=None,
                       visible=True,
                       direction=TextDirection.LTR):
        """Return a new created language.

        :arg code: ISO 639 language code.
        :arg englishname: English name for the new language.
        :arg nativename: Native language name.
        :arg pluralforms: Number of plural forms.
        :arg pluralexpression: Plural form expression.
        :arg visible: Whether this language should be showed by default.
        :arg direction: Text direction, either 'left to right' or 'right to
            left'.
        """

    def search(text):
        """Return a result set of ILanguage that match the search."""
コード例 #17
0
class IBugTrackerSet(Interface):
    """A set of IBugTracker's.

    Each BugTracker is a distinct instance of a bug tracking tool. For
    example, bugzilla.mozilla.org is distinct from bugzilla.gnome.org.
    """
    export_as_webservice_collection(IBugTracker)

    title = Attribute('Title')

    count = Attribute("The number of registered bug trackers.")

    names = Attribute("The names of all registered bug trackers.")

    def get(bugtracker_id, default=None):
        """Get a BugTracker by its id.

        If no tracker with the given id exists, return default.
        """

    @operation_parameters(
        name=TextLine(title=u"The bug tracker name", required=True))
    @operation_returns_entry(IBugTracker)
    @export_read_operation()
    def getByName(name, default=None):
        """Get a BugTracker by its name.

        If no tracker with the given name exists, return default.
        """

    def __getitem__(name):
        """Get a BugTracker by its name in the database.

        Note: We do not want to expose the BugTracker.id to the world
        so we use its name.
        """

    def __iter__():
        """Iterate through BugTrackers."""

    @rename_parameters_as(baseurl='base_url')
    @operation_parameters(
        baseurl=TextLine(
            title=u"The base URL of the bug tracker", required=True))
    @operation_returns_entry(IBugTracker)
    @export_read_operation()
    def queryByBaseURL(baseurl):
        """Return one or None BugTracker's by baseurl"""

    @call_with(owner=REQUEST_USER)
    @rename_parameters_as(
        baseurl='base_url', bugtrackertype='bug_tracker_type',
        contactdetails='contact_details')
    @export_factory_operation(
        IBugTracker,
        ['baseurl', 'bugtrackertype', 'title', 'summary',
         'contactdetails', 'name'])
    def ensureBugTracker(baseurl, owner, bugtrackertype,
        title=None, summary=None, contactdetails=None, name=None):
        """Make sure that there is a bugtracker for the given base url.

        If not, create one using the given attributes.
        """

    @collection_default_content()
    def search():
        """Search all the IBugTrackers in the system."""

    def getMostActiveBugTrackers(limit=None):
        """Return the top IBugTrackers.

        Returns a list of IBugTracker objects, ordered by the number
        of bugwatches for each tracker, from highest to lowest.
        """

    def getPillarsForBugtrackers(bug_trackers, user=None):
        """Return dict mapping bugtrackers to lists of pillars."""

    def getAllTrackers(active=None):
        """Return a ResultSet of bugtrackers.
コード例 #18
0
class IGitRepositorySet(Interface):
    """Interface representing the set of Git repositories."""

    export_as_webservice_collection(IGitRepository)

    def new(registrant,
            owner,
            target,
            name,
            information_type=None,
            date_created=None):
        """Create a Git repository and return it.

        :param registrant: The `IPerson` who registered the new repository.
        :param owner: The `IPerson` who owns the new repository.
        :param target: The `IProduct`, `IDistributionSourcePackage`, or
            `IPerson` that the new repository is associated with.
        :param name: The repository name.
        :param information_type: Set the repository's information type to
            one different from the target's default.  The type must conform
            to the target's code sharing policy.  (optional)
        """

    # Marker for references to Git URL layouts: ##GITNAMESPACE##
    @call_with(user=REQUEST_USER)
    @operation_parameters(path=TextLine(title=_("Repository path"),
                                        required=True))
    @operation_returns_entry(IGitRepository)
    @export_read_operation()
    @operation_for_version("devel")
    def getByPath(user, path):
        """Find a repository by its path.

        Any of these forms may be used::

            Unique names:
                ~OWNER/PROJECT/+git/NAME
                ~OWNER/DISTRO/+source/SOURCE/+git/NAME
                ~OWNER/+git/NAME
            Owner-target default aliases:
                ~OWNER/PROJECT
                ~OWNER/DISTRO/+source/SOURCE
            Official aliases:
                PROJECT
                DISTRO/+source/SOURCE

        Return None if no match was found.
        """

    @call_with(user=REQUEST_USER)
    @operation_parameters(target=Reference(title=_("Target"),
                                           required=True,
                                           schema=IHasGitRepositories))
    @operation_returns_collection_of(IGitRepository)
    @export_read_operation()
    @operation_for_version("devel")
    def getRepositories(user, target):
        """Get all repositories for a target.

        :param user: An `IPerson`.  Only repositories visible by this user
            will be returned.
        :param target: An `IHasGitRepositories`.

        :return: A collection of `IGitRepository` objects.
        """

    @call_with(user=REQUEST_USER)
    @operation_parameters(
        person=Reference(title=_(
            "The person whose repository visibility is being "
            "checked."),
                         schema=IPerson),
        repository_names=List(value_type=Text(),
                              title=_('List of repository unique names'),
                              required=True),
    )
    @export_read_operation()
    @operation_for_version("devel")
    def getRepositoryVisibilityInfo(user, person, repository_names):
        """Return the named repositories visible to both user and person.

        Anonymous requesters don't get any information.

        :param user: The user requesting the information. If the user is
            None then we return an empty dict.
        :param person: The person whose repository visibility we wish to
            check.
        :param repository_names: The unique names of the repositories to
            check.

        Return a dict with the following values:
        person_name: the displayname of the person.
        visible_repositories: a list of the unique names of the repositories
        which the requester and specified person can both see.

        This API call is provided for use by the client Javascript.  It is
        not designed to efficiently scale to handle requests for large
        numbers of repositories.
        """

    @operation_parameters(target=Reference(title=_("Target"),
                                           required=True,
                                           schema=IHasGitRepositories))
    @operation_returns_entry(IGitRepository)
    @export_read_operation()
    @operation_for_version("devel")
    def getDefaultRepository(target):
        """Get the default repository for a target.

        :param target: An `IHasGitRepositories`.

        :raises GitTargetError: if `target` is an `IPerson`.
        :return: An `IGitRepository`, or None.
        """

    @operation_parameters(owner=Reference(title=_("Owner"),
                                          required=True,
                                          schema=IPerson),
                          target=Reference(title=_("Target"),
                                           required=True,
                                           schema=IHasGitRepositories))
    @operation_returns_entry(IGitRepository)
    @export_read_operation()
    @operation_for_version("devel")
    def getDefaultRepositoryForOwner(owner, target):
        """Get a person's default repository for a target.

        :param owner: An `IPerson`.
        :param target: An `IHasGitRepositories`.

        :raises GitTargetError: if `target` is an `IPerson`.
        :return: An `IGitRepository`, or None.
        """

    @operation_parameters(target=Reference(title=_("Target"),
                                           required=True,
                                           schema=IHasGitRepositories),
                          repository=Reference(title=_("Git repository"),
                                               required=False,
                                               schema=IGitRepository))
    @export_write_operation()
    @operation_for_version("devel")
    def setDefaultRepository(target, repository):
        """Set the default repository for a target.

        :param target: An `IHasGitRepositories`.
        :param repository: An `IGitRepository`, or None to unset the default
            repository.

        :raises GitTargetError: if `target` is an `IPerson`.
        """

    @call_with(user=REQUEST_USER)
    @operation_parameters(owner=Reference(title=_("Owner"),
                                          required=True,
                                          schema=IPerson),
                          target=Reference(title=_("Target"),
                                           required=True,
                                           schema=IHasGitRepositories),
                          repository=Reference(title=_("Git repository"),
                                               required=False,
                                               schema=IGitRepository))
    @export_write_operation()
    @operation_for_version("devel")
    def setDefaultRepositoryForOwner(owner, target, repository, user):
        """Set a person's default repository for a target.

        :param owner: An `IPerson`.
        :param target: An `IHasGitRepositories`.
        :param repository: An `IGitRepository`, or None to unset the default
            repository.
        :param user: The `IPerson` who is making the change.

        :raises GitTargetError: if `target` is an `IPerson`.
        """

    @collection_default_content()
    def empty_list():
        """Return an empty collection of repositories.

        This only exists to keep lazr.restful happy.
        """

    def preloadDefaultRepositoriesForProjects(projects):
        """Get preloaded default repositories for a list of projects.
コード例 #19
0
ファイル: snap.py プロジェクト: pombredanne/launchpad-3
class ISnapSet(Interface):
    """A utility to create and access snap packages."""

    export_as_webservice_collection(ISnap)

    @call_with(registrant=REQUEST_USER)
    @operation_parameters(
        processors=List(
            value_type=Reference(schema=IProcessor), required=False))
    @export_factory_operation(
        ISnap, [
            "owner", "distro_series", "name", "description", "branch",
            "git_repository", "git_repository_url", "git_path", "git_ref",
            "auto_build", "auto_build_archive", "auto_build_pocket",
            "private", "store_upload", "store_series", "store_name",
            "store_channels"])
    @operation_for_version("devel")
    def new(registrant, owner, distro_series, name, description=None,
            branch=None, git_repository=None, git_repository_url=None,
            git_path=None, git_ref=None, auto_build=False,
            auto_build_archive=None, auto_build_pocket=None,
            require_virtualized=True, processors=None, date_created=None,
            private=False, store_upload=False, store_series=None,
            store_name=None, store_secrets=None, store_channels=None):
        """Create an `ISnap`."""

    def exists(owner, name):
        """Check to see if a matching snap exists."""

    def isValidPrivacy(private, owner, branch=None, git_ref=None):
        """Whether or not the privacy context is valid."""

    @operation_parameters(
        owner=Reference(IPerson, title=_("Owner"), required=True),
        name=TextLine(title=_("Snap name"), required=True))
    @operation_returns_entry(ISnap)
    @export_read_operation()
    @operation_for_version("devel")
    def getByName(owner, name):
        """Return the appropriate `ISnap` for the given objects."""

    @operation_parameters(
        owner=Reference(IPerson, title=_("Owner"), required=True))
    @operation_returns_collection_of(ISnap)
    @export_read_operation()
    @operation_for_version("devel")
    def findByOwner(owner):
        """Return all snap packages with the given `owner`."""

    def findByPerson(person, visible_by_user=None):
        """Return all snap packages relevant to `person`.

        This returns snap packages for Bazaar or Git branches owned by
        `person`, or where `person` is the owner of the snap package.

        :param person: An `IPerson`.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        """

    def findByProject(project, visible_by_user=None):
        """Return all snap packages for the given project.

        :param project: An `IProduct`.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        """

    def findByBranch(branch):
        """Return all snap packages for the given Bazaar branch."""

    def findByGitRepository(repository, paths=None):
        """Return all snap packages for the given Git repository.

        :param repository: An `IGitRepository`.
        :param paths: If not None, only return snap packages for one of
            these Git reference paths.
        """

    def findByGitRef(ref):
        """Return all snap packages for the given Git reference."""

    def findByContext(context, visible_by_user=None, order_by_date=True):
        """Return all snap packages for the given context.

        :param context: An `IPerson`, `IProduct, `IBranch`,
            `IGitRepository`, or `IGitRef`.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        :param order_by_date: If True, order packages by descending
            modification date.
        :raises BadSnapSearchContext: if the context is not understood.
        """

    @operation_parameters(
        url=TextLine(title=_("The URL to search for.")),
        owner=Reference(IPerson, title=_("Owner"), required=False))
    @call_with(visible_by_user=REQUEST_USER)
    @operation_returns_collection_of(ISnap)
    @export_read_operation()
    @operation_for_version("devel")
    def findByURL(url, owner=None, visible_by_user=None):
        """Return all snap packages that build from the given URL.

        This currently only works for packages that build directly from a
        URL, rather than being linked to a Bazaar branch or Git repository
        hosted in Launchpad.

        :param url: A URL.
        :param owner: Only return packages owned by this user.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        """

    @operation_parameters(
        url_prefix=TextLine(title=_("The URL prefix to search for.")),
        owner=Reference(IPerson, title=_("Owner"), required=False))
    @call_with(visible_by_user=REQUEST_USER)
    @operation_returns_collection_of(ISnap)
    @export_read_operation()
    @operation_for_version("devel")
    def findByURLPrefix(url_prefix, owner=None, visible_by_user=None):
        """Return all snap packages that build from a URL with this prefix.

        This currently only works for packages that build directly from a
        URL, rather than being linked to a Bazaar branch or Git repository
        hosted in Launchpad.

        :param url_prefix: A URL prefix.
        :param owner: Only return packages owned by this user.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        """

    @operation_parameters(
        url_prefixes=List(
            title=_("The URL prefixes to search for."), value_type=TextLine()),
        owner=Reference(IPerson, title=_("Owner"), required=False))
    @call_with(visible_by_user=REQUEST_USER)
    @operation_returns_collection_of(ISnap)
    @export_read_operation()
    @operation_for_version("devel")
    def findByURLPrefixes(url_prefixes, owner=None, visible_by_user=None):
        """Return all snap packages that build from a URL with any of these
        prefixes.

        This currently only works for packages that build directly from a
        URL, rather than being linked to a Bazaar branch or Git repository
        hosted in Launchpad.

        :param url_prefixes: A list of URL prefixes.
        :param owner: Only return packages owned by this user.
        :param visible_by_user: If not None, only return packages visible by
            this user; otherwise, only return publicly-visible packages.
        """

    def preloadDataForSnaps(snaps, user):
        """Load the data related to a list of snap packages."""

    def getSnapcraftYaml(context, logger=None):
        """Fetch a package's snapcraft.yaml from code hosting, if possible.

        :param context: Either an `ISnap` or the source branch for a snap
            package.
        :param logger: An optional logger.

        :return: The package's parsed snapcraft.yaml.
        :raises MissingSnapcraftYaml: if this package has no snapcraft.yaml.
        :raises CannotFetchSnapcraftYaml: if it was not possible to fetch
            snapcraft.yaml from the code hosting backend for some other
            reason.
        :raises CannotParseSnapcraftYaml: if the fetched snapcraft.yaml
            cannot be parsed.
        """

    def makeAutoBuilds(logger=None):
        """Create and return automatic builds for stale snap packages.

        :param logger: An optional logger.
        """

    def detachFromBranch(branch):
        """Detach all snap packages from the given Bazaar branch.

        After this, any snap packages that previously used this branch will
        have no source and so cannot dispatch new builds.
        """

    def detachFromGitRepository(repository):
        """Detach all snap packages from the given Git repository.

        After this, any snap packages that previously used this repository
        will have no source and so cannot dispatch new builds.
        """

    @collection_default_content()
    def empty_list():
        """Return an empty collection of snap packages.
コード例 #20
0
ファイル: packageset.py プロジェクト: pombredanne/launchpad-3
class IPackagesetSet(IPackagesetSetEdit):
    """An interface for multiple package sets."""
    export_as_webservice_collection(IPackageset)

    @operation_parameters(name=copy_field(IPackageset['name']),
                          distroseries=copy_field(IPackageset['distroseries']))
    @operation_returns_entry(IPackageset)
    @export_read_operation()
    def getByName(distroseries, name):
        """Return the single package set with the given name (if any).

        :param distroseries: the distroseries to which the new packageset
            is related.
        :param name: the name of the package set sought.

        :return: An `IPackageset` instance.
        :raise NoSuchPackageSet: if no package set is found.
        """

    @collection_default_content()
    def get():
        """Return all of the package sets in Launchpad.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    def getByOwner(owner):
        """Return the package sets belonging to the given owner (if any).

        :param owner: the owner of the package sets sought.

        :return: A (potentially empty) sequence of `IPackageset` instances.
        """

    @operation_parameters(distroseries=copy_field(
        IPackageset['distroseries'],
        description=_("The distribution series to which the packagesets "
                      "are related.")))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    @operation_for_version("beta")
    def getBySeries(distroseries):
        """Return the package sets associated with the given distroseries.

        :param distroseries: A `DistroSeries`.

        :return: An iterable collection of `IPackageset` instances.
        """

    def getForPackages(distroseries, sourcepackagename_ids):
        """Get `Packagesets` that directly contain the given packages.

        :param distroseries: `DistroSeries` to look in.  Only packagesets for
            this series will be returned.
        :param sourcepackagename_ids: A sequence of `SourcePackageName` ids.
            Only packagesets for these package names will be returned.
        :return: A dict mapping `SourcePackageName` ids to lists of their
            respective packagesets, in no particular order.
        """

    @operation_parameters(sourcepackagename=TextLine(
        title=_('Source package name'), required=True),
                          distroseries=copy_field(IPackageset['distroseries'],
                                                  required=False),
                          direct_inclusion=Bool(required=False))
    @operation_returns_collection_of(IPackageset)
    @export_read_operation()
    def setsIncludingSource(sourcepackagename,
                            distroseries=None,
                            direct_inclusion=False):
        """Get the package sets that include this source package.
コード例 #21
0
class ISpecificationSet(IHasSpecifications):
    """A container for specifications."""
    export_as_webservice_collection(ISpecification)

    @collection_default_content()
    def empty_list():
        """Return an empty set - only exists to keep lazr.restful happy."""

    displayname = Attribute('Displayname')

    title = Attribute('Title')

    coming_sprints = Attribute("The next 5 sprints in the system.")

    def specificationCount(user):
        """The total number of blueprints in Launchpad"""

    def getStatusCountsForProductSeries(product_series):
        """Return the status counts for blueprints in a series.

        Both the nominated and scheduled blueprints are included
        in the count.

        :param product_series: ProductSeries object.
        :return: A list of tuples containing (status, count).
        """

    def getByURL(url):
        """Return the specification with the given url."""

    def getByName(pillar, name):
        """Return the specification with the given name for the given pillar.
        """

    @call_with(owner=REQUEST_USER)
    @export_operation_as('createSpecification')
    @operation_parameters(target=Reference(
        schema=ISpecificationTarget,
        required=True,
        title=(u"The product or distribution context of this "
               u"specification.")))
    @export_factory_operation(ISpecification, [
        'name', 'title', 'specurl', 'summary', 'definition_status', 'assignee',
        'drafter', 'whiteboard'
    ])
    @operation_for_version('devel')
    def new(name,
            title,
            specurl,
            summary,
            definition_status,
            owner,
            target,
            approver=None,
            assignee=None,
            drafter=None,
            whiteboard=None,
            information_type=None):
        """Create a new specification."""

    def getDependencyDict(specifications):
        """Return a dictionary mapping specifications to their dependencies.

        The results are ordered by descending priority, ascending dependency
        name, and id.

        :param specifications: a sequence of the `ISpecification` to look up.
        """

    def get(spec_id):
        """Return the ISpecification with the given spec_id."""