<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 conary groups.
"""

import logging

from conary import versions

from updatebot.build import Builder

from updatebot.errors import NotCommittingOutOfDateSourceError

from updatebot.groupmgr.group import Group
from updatebot.groupmgr.group import require_write
from updatebot.groupmgr.helper import GroupHelper
from updatebot.groupmgr.sanity import GroupSanityChecker

log = logging.getLogger('updatebot.groupmgr')

class GroupManager(object):
    """
    Class for managing groups.
    @param cfg: updatebot configuration object
    @type cfg: updatebot.config.UpdateBotConfig
    @param parentGroup: optional argument, if set to True will setup manager to
                        interact with the parent platform group contents. This
                        is automatically set to readonly to avoid writing
                        anything to the parent platform.
    @type parentGroup: boolean
    @param targetGroup: optional argument, if set to True will setup manager to
                        interact with the target "production" branch for the
                        configured platform. This manager instance will
                        automatically be set to readonly to avoid modifying the
                        target label.
    @type targetGroup: boolean
    @param useMap: optional argument, A dictionary of package names mapped to a
                   list of use flags for the given package name. This is used to
                   determine use flags for packages that are added to group
                   contents models. If not specified all x86 packages will be
                   added to the x86 group and all x86_64 packages will be added
                   to the x86_64 group.
    @type useMap: dict
    """

    _helperClass = GroupHelper
    _sanityCheckerClass = GroupSanityChecker

    def __init__(self, cfg, parentGroup=False, targetGroup=False, useMap=None):
        self._cfg = cfg

        if useMap is None:
            self._useMap = {}
        else:
            self._useMap = useMap

        self._helper = self._helperClass(self._cfg)
        self._builder = Builder(self._cfg, rmakeCfgFn='rmakerc-groups')
        self._sanity = self._sanityCheckerClass(self._cfg, self._helper)

        assert not (parentGroup and targetGroup)

        srcName = '%s:source' % self._cfg.topSourceGroup[0]
        srcLabel = self._cfg.topSourceGroup[1]
        labels = None

        if targetGroup:
            srcLabel = self._cfg.targetLabel
        elif parentGroup:
            srcName = self._cfg.topParentSourceGroup[0]
            srcLabel = self._cfg.topParentSourceGroup[1]
            labels = self._cfg.platformSearchPath
<commit_msg>remove redundant :source<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 conary groups.
"""

import logging

from conary import versions

from updatebot.build import Builder

from updatebot.errors import NotCommittingOutOfDateSourceError

from updatebot.groupmgr.group import Group
from updatebot.groupmgr.group import require_write
from updatebot.groupmgr.helper import GroupHelper
from updatebot.groupmgr.sanity import GroupSanityChecker

log = logging.getLogger('updatebot.groupmgr')

class GroupManager(object):
    """
    Class for managing groups.
    @param cfg: updatebot configuration object
    @type cfg: updatebot.config.UpdateBotConfig
    @param parentGroup: optional argument, if set to True will setup manager to
                        interact with the parent platform group contents. This
                        is automatically set to readonly to avoid writing
                        anything to the parent platform.
    @type parentGroup: boolean
    @param targetGroup: optional argument, if set to True will setup manager to
                        interact with the target "production" branch for the
                        configured platform. This manager instance will
                        automatically be set to readonly to avoid modifying the
                        target label.
    @type targetGroup: boolean
    @param useMap: optional argument, A dictionary of package names mapped to a
                   list of use flags for the given package name. This is used to
                   determine use flags for packages that are added to group
                   contents models. If not specified all x86 packages will be
                   added to the x86 group and all x86_64 packages will be added
                   to the x86_64 group.
    @type useMap: dict
    """

    _helperClass = GroupHelper
    _sanityCheckerClass = GroupSanityChecker

    def __init__(self, cfg, parentGroup=False, targetGroup=False, useMap=None):
        self._cfg = cfg

        if useMap is None:
            self._useMap = {}
        else:
            self._useMap = useMap

        self._helper = self._helperClass(self._cfg)
        self._builder = Builder(self._cfg, rmakeCfgFn='rmakerc-groups')
        self._sanity = self._sanityCheckerClass(self._cfg, self._helper)

        assert not (parentGroup and targetGroup)

        srcName = self._cfg.topSourceGroup[0]
        srcLabel = self._cfg.topSourceGroup[1]
        labels = None

        if targetGroup:
            srcLabel = self._cfg.targetLabel
        elif parentGroup:
            srcName = self._cfg.topParentSourceGroup[0]
            srcLabel = self._cfg.topParentSourceGroup[1]
            labels = self._cfg.platformSearchPath

{'fraction_non_alphanumeric': 0.05605211331616422, 'fraction_numerical': 0.008483563096500531, 'mean_word_length': 2.5437466451959208, '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': '4126260', 'n_tokens_mistral': 1654, 'n_tokens_neox': 1611, 'n_words': 661}