Пример #1
0
 def create(self, regexp, comment=None, admin=None):
     """See `INameBlacklistSet`."""
     nameblacklist = NameBlacklist()
     nameblacklist.regexp = regexp
     nameblacklist.comment = comment
     nameblacklist.admin = admin
     store = IStore(NameBlacklist)
     store.add(nameblacklist)
     return nameblacklist
Пример #2
0
 def create(self, regexp, comment=None, admin=None):
     """See `INameBlacklistSet`."""
     nameblacklist = NameBlacklist()
     nameblacklist.regexp = regexp
     nameblacklist.comment = comment
     nameblacklist.admin = admin
     store = IStore(NameBlacklist)
     store.add(nameblacklist)
     return nameblacklist
Пример #3
0
    def addComponent(self, component_name):
        """Adds a component that is synced from a remote bug tracker"""

        component = BugTrackerComponent()
        component.name = component_name
        component.component_group = self

        store = IStore(BugTrackerComponent)
        store.add(component)
        store.flush()

        return component
Пример #4
0
def create_missing_pofiletranslators(logger, pofile, pofts, contribs):
    """Create `POFileTranslator` records that were missing."""
    shortage = set(contribs) - pofts
    if len(shortage) == 0:
        return
    logger.debug("Adding %d POFileTranslator(s) for %s.", len(shortage),
                 pofile.title)
    store = IStore(pofile)
    for missing_contributor in shortage:
        store.add(
            POFileTranslator(pofile=pofile,
                             personID=missing_contributor,
                             date_last_touched=contribs[missing_contributor]))
Пример #5
0
    def test_branches(self):
        """Test that a merge queue can get all its managed branches."""
        store = IStore(BranchMergeQueue)

        queue = self.factory.makeBranchMergeQueue()
        store.add(queue)

        branch = self.factory.makeBranch()
        store.add(branch)
        with person_logged_in(branch.owner):
            branch.addToQueue(queue)

        self.assertEqual(list(queue.branches), [branch])
    def makeJob(self):
        """See `IBuildFarmJobOld`."""
        store = IStore(BranchJob)

        # Pass public HTTP URL for the branch.
        metadata = {
            'branch_url': self.branch.composePublicURL(),
            'build_id': self.id,
            }
        branch_job = BranchJob(
            self.branch, BranchJobType.TRANSLATION_TEMPLATES_BUILD, metadata)
        store.add(branch_job)
        return TranslationTemplatesBuildJob(branch_job)
def create_missing_pofiletranslators(logger, pofile, pofts, contribs):
    """Create `POFileTranslator` records that were missing."""
    shortage = set(contribs) - pofts
    if len(shortage) == 0:
        return
    logger.debug(
        "Adding %d POFileTranslator(s) for %s.",
        len(shortage), pofile.title)
    store = IStore(pofile)
    for missing_contributor in shortage:
        store.add(POFileTranslator(
            pofile=pofile, personID=missing_contributor,
            date_last_touched=contribs[missing_contributor]))
Пример #8
0
    def makeJob(self):
        """See `IBuildFarmJobOld`."""
        store = IStore(BranchJob)

        # Pass public HTTP URL for the branch.
        metadata = {
            'branch_url': self.branch.composePublicURL(),
            'build_id': self.id,
        }
        branch_job = BranchJob(self.branch,
                               BranchJobType.TRANSLATION_TEMPLATES_BUILD,
                               metadata)
        store.add(branch_job)
        return TranslationTemplatesBuildJob(branch_job)
Пример #9
0
    def addRemoteComponentGroup(self, component_group_name):
        """See `IBugTracker`."""

        if component_group_name is None:
            component_group_name = "default"
        component_group = BugTrackerComponentGroup()
        component_group.name = component_group_name
        component_group.bug_tracker = self

        store = IStore(BugTrackerComponentGroup)
        store.add(component_group)
        store.commit()

        return component_group
Пример #10
0
    def addCustomComponent(self, component_name):
        """Adds a component locally that isn't synced from a remote tracker
        """

        component = BugTrackerComponent()
        component.name = component_name
        component.component_group = self
        component.is_custom = True

        store = IStore(BugTrackerComponent)
        store.add(component)
        store.flush()

        return component
Пример #11
0
 def addActivity(self, result=None, message=None, oops_id=None):
     """See `IBugWatch`."""
     activity = BugWatchActivity()
     activity.bug_watch = self
     if result is None:
         # If no result is passed we assume that the activity
         # succeded and set the result field accordingly.
         activity.result = BugWatchActivityStatus.SYNC_SUCCEEDED
     else:
         activity.result = result
     if message is not None:
         activity.message = unicode(message)
     if oops_id is not None:
         activity.oops_id = unicode(oops_id)
     store = IStore(BugWatchActivity)
     store.add(activity)
Пример #12
0
 def addActivity(self, result=None, message=None, oops_id=None):
     """See `IBugWatch`."""
     activity = BugWatchActivity()
     activity.bug_watch = self
     if result is None:
         # If no result is passed we assume that the activity
         # succeded and set the result field accordingly.
         activity.result = BugWatchActivityStatus.SYNC_SUCCEEDED
     else:
         activity.result = result
     if message is not None:
         activity.message = unicode(message)
     if oops_id is not None:
         activity.oops_id = unicode(oops_id)
     store = IStore(BugWatchActivity)
     store.add(activity)
Пример #13
0
 def _set_collection(self, cls, enum, attribute, current_set, desired_set):
     desired_set = frozenset(desired_set)
     if desired_set == frozenset(enum.items):
         # Setting all is the same as setting none, and setting none is
         # cheaper for reading and storage.
         desired_set = frozenset()
     # Add missing.
     store = IStore(cls)
     for kind in desired_set.difference(current_set):
         bsf = cls()
         bsf.filter = self
         setattr(bsf, attribute, kind)
         store.add(bsf)
     # Remove unused.
     kind = getattr(cls, attribute)
     store.find(cls, cls.filter == self,
                kind.is_in(current_set.difference(desired_set))).remove()
    def _set_tags(self, tags):
        """Update the tags to filter on.

        The tags can be qualified with a leading hyphen, and can be bundled in
        any iterable.

        If they are passed within a `searchbuilder.any` or `searchbuilder.all`
        object, the `find_all_tags` attribute will be updated to match.

        Wildcard tags - `*` and `-*` - can be given too, and will update
        `include_any_tags` and `exclude_any_tags`.
        """
        # Deal with searchbuilder terms.
        if isinstance(tags, searchbuilder.all):
            self.find_all_tags = True
            tags = frozenset(tags.query_values)
        elif isinstance(tags, searchbuilder.any):
            self.find_all_tags = False
            tags = frozenset(tags.query_values)
        else:
            # Leave find_all_tags unchanged.
            tags = frozenset(tags)
        wildcards = frozenset((u"*", u"-*")).intersection(tags)
        # Set wildcards.
        self.include_any_tags = "*" in wildcards
        self.exclude_any_tags = "-*" in wildcards
        # Deal with other tags.
        tags = tags - wildcards
        store = IStore(BugSubscriptionFilterTag)
        current_tag_filters = dict(
            (tag_filter.qualified_tag, tag_filter)
            for tag_filter in store.find(
                BugSubscriptionFilterTag,
                BugSubscriptionFilterTag.filter == self))
        # Remove unused tags.
        for tag in set(current_tag_filters).difference(tags):
            tag_filter = current_tag_filters.pop(tag)
            store.remove(tag_filter)
        # Add additional tags.
        for tag in tags.difference(current_tag_filters):
            tag_filter = BugSubscriptionFilterTag()
            tag_filter.filter = self
            tag_filter.include = not tag.startswith("-")
            tag_filter.tag = tag.lstrip("-")
            store.add(tag_filter)
Пример #15
0
    def _set_tags(self, tags):
        """Update the tags to filter on.

        The tags can be qualified with a leading hyphen, and can be bundled in
        any iterable.

        If they are passed within a `searchbuilder.any` or `searchbuilder.all`
        object, the `find_all_tags` attribute will be updated to match.

        Wildcard tags - `*` and `-*` - can be given too, and will update
        `include_any_tags` and `exclude_any_tags`.
        """
        # Deal with searchbuilder terms.
        if isinstance(tags, searchbuilder.all):
            self.find_all_tags = True
            tags = frozenset(tags.query_values)
        elif isinstance(tags, searchbuilder.any):
            self.find_all_tags = False
            tags = frozenset(tags.query_values)
        else:
            # Leave find_all_tags unchanged.
            tags = frozenset(tags)
        wildcards = frozenset((u"*", u"-*")).intersection(tags)
        # Set wildcards.
        self.include_any_tags = "*" in wildcards
        self.exclude_any_tags = "-*" in wildcards
        # Deal with other tags.
        tags = tags - wildcards
        store = IStore(BugSubscriptionFilterTag)
        current_tag_filters = dict(
            (tag_filter.qualified_tag, tag_filter)
            for tag_filter in store.find(
                BugSubscriptionFilterTag, BugSubscriptionFilterTag.filter ==
                self))
        # Remove unused tags.
        for tag in set(current_tag_filters).difference(tags):
            tag_filter = current_tag_filters.pop(tag)
            store.remove(tag_filter)
        # Add additional tags.
        for tag in tags.difference(current_tag_filters):
            tag_filter = BugSubscriptionFilterTag()
            tag_filter.filter = self
            tag_filter.include = not tag.startswith("-")
            tag_filter.tag = tag.lstrip("-")
            store.add(tag_filter)
 def _set_collection(self, cls, enum, attribute, current_set, desired_set):
     desired_set = frozenset(desired_set)
     if desired_set == frozenset(enum.items):
         # Setting all is the same as setting none, and setting none is
         # cheaper for reading and storage.
         desired_set = frozenset()
     # Add missing.
     store = IStore(cls)
     for kind in desired_set.difference(current_set):
         bsf = cls()
         bsf.filter = self
         setattr(bsf, attribute, kind)
         store.add(bsf)
     # Remove unused.
     kind = getattr(cls, attribute)
     store.find(
         cls, cls.filter == self, kind.is_in(
             current_set.difference(desired_set))).remove()