<commit_before>#
# Copyright (c) 2009-2010 rPath, Inc.
#
# This program is distributed under the terms of the Common Public License,
# version 1.0. A copy of this license should have been distributed with this
# source file in a file called LICENSE. If it is not present, the license
# is always available at http://www.rpath.com/permanent/licenses/CPL-1.0.
#
# This program is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the Common Public License for
# full details.
#

"""
Module for managing groups that contain only packages with no subgroups.
"""

from updatebot.groupmgr.helper import GroupHelper
from updatebot.groupmgr.manager import GroupManager

class SingleGroupHelper(GroupHelper):
    """
    Group helper for managing groups with only packages and no other groups.
    """

    def __init__(self, *args, **kwargs):
        GroupHelper.__init__(self, *args, **kwargs)
        self._groupContents = {}


class SingleGroupManager(GroupManager):
    """
    Class to manage a single group that contains only packages with no
    subgroups.
    """

    _helperClass = SingleGroupHelper

    def __init__(self, name, *args, **kwargs):
        GroupManager.__init__(self, *args, **kwargs)
        self._sourceName = 'group-%s' % name
        self._pkgGroupName = self._sourceName


class SingleGroupManagerSet(object):
    """
    Class for working with a set of group manager instances.
    """

    _managerClass = SingleGroupManager

    def __init__(self, cfg):
        self._cfg = cfg
        self._groups = {}

    def newGroup(self, name):
        """
        Create a new group instance with the provided name.
        """

        assert name not in self._groups
        group = self._managerClass(name, self._cfg)
        self._groups[name] = group
        return group

    def build(self):
        """
        Build all groups in the set.
        """

        # Make sure there are groups defined
        assert self._groups

        toBuild = set()
        builder = None
        for group in self._groups.itervalues():
            # Select the builder from the first instance to build all groups.
            if not builder:
                builder = group._builder

            # Get the build job for each group.
            trvSpecs = group.getBuildJob()
            assert len(trvSpecs) == 1
            toBuild.add(trvSpecs[0])

        # Build all groups in separate jobs, waiting until all have completed
        # to commit.
        return builder.buildmany(toBuild, lateCommit=True)<commit_msg>add method for querying groups switch to cvc builder<commit_after>#
# Copyright (c) 2009-2010 rPath, Inc.
#
# This program is distributed under the terms of the Common Public License,
# version 1.0. A copy of this license should have been distributed with this
# source file in a file called LICENSE. If it is not present, the license
# is always available at http://www.rpath.com/permanent/licenses/CPL-1.0.
#
# This program is distributed in the hope that it will be useful, but
# without any warranty; without even the implied warranty of merchantability
# or fitness for a particular purpose. See the Common Public License for
# full details.
#

"""
Module for managing groups that contain only packages with no subgroups.
"""

from updatebot.groupmgr.helper import GroupHelper
from updatebot.groupmgr.manager import GroupManager

class SingleGroupHelper(GroupHelper):
    """
    Group helper for managing groups with only packages and no other groups.
    """

    def __init__(self, *args, **kwargs):
        GroupHelper.__init__(self, *args, **kwargs)
        self._groupContents = {}


class SingleGroupManager(GroupManager):
    """
    Class to manage a single group that contains only packages with no
    subgroups.
    """

    _helperClass = SingleGroupHelper

    def __init__(self, name, *args, **kwargs):
        GroupManager.__init__(self, *args, **kwargs)
        self._sourceName = 'group-%s' % name
        self._pkgGroupName = self._sourceName


class SingleGroupManagerSet(object):
    """
    Class for working with a set of group manager instances.
    """

    _managerClass = SingleGroupManager

    def __init__(self, cfg):
        self._cfg = cfg
        self._groups = {}

    def newGroup(self, name):
        """
        Create a new group instance with the provided name.
        """

        assert name not in self._groups
        group = self._managerClass(name, self._cfg)
        self._groups[name] = group
        return group

    def build(self):
        """
        Build all groups in the set.
        """

        # Make sure there are groups defined
        assert self._groups

        pkgMap = {}
        for group in self._groups.itervalues():
            pkgMap.update(group.build())

        return pkgMap

    def hasGroups(self):
        """
        Add method for checking if a manager has any groups defined.
        """

        return bool(self._groups)
{'fraction_non_alphanumeric': 0.08196721311475409, 'fraction_numerical': 0.00513529527947857, 'mean_word_length': 2.643165467625899, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2618798', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1296, 'n_words': 519}