Esempio n. 1
0
    def pkg_grp_to_libcomps(self):
        """
        Convert PackageGroup object to libcomps Group object.

        Returns:
            group: libcomps.Group object

        """
        group = libcomps.Group()

        group.id = getattr(self, PULP_GROUP_ATTRS.ID)
        group.default = getattr(self, PULP_GROUP_ATTRS.DEFAULT)
        group.uservisible = getattr(self, PULP_GROUP_ATTRS.USER_VISIBLE)
        group.display_order = getattr(self, PULP_GROUP_ATTRS.DISPLAY_ORDER)
        group.name = getattr(self, PULP_GROUP_ATTRS.NAME)
        group.desc = getattr(self, PULP_GROUP_ATTRS.DESCRIPTION)
        group.packages = self.list_to_pkglist(
            getattr(self, PULP_GROUP_ATTRS.PACKAGES))
        group.biarchonly = getattr(self, PULP_GROUP_ATTRS.BIARCH_ONLY)
        group.desc_by_lang = dict_to_strdict(
            getattr(self, PULP_GROUP_ATTRS.DESC_BY_LANG))
        group.name_by_lang = dict_to_strdict(
            getattr(self, PULP_GROUP_ATTRS.NAME_BY_LANG))

        return group
Esempio n. 2
0
def pkg_grp_to_libcomps(obj):
    """
    Convert PackageGroup object to libcomps Group object.

    Args:
        obj(Pulp2PackageGroup): Pulp2PackageGroup

    Returns:
        group: libcomps.Group object

    """
    group = libcomps.Group()

    group.id = obj.package_group_id
    group.default = obj.default
    group.uservisible = obj.user_visible
    group.display_order = obj.display_order
    group.name = obj.name
    group.desc = obj.description
    group.packages = _list_to_pkglist(obj.packages)
    group.biarchonly = obj.biarch_only
    group.desc_by_lang = dict_to_strdict(obj.desc_by_lang)
    group.name_by_lang = dict_to_strdict(obj.name_by_lang)

    return group
Esempio n. 3
0
    def run(self):
        self.load_input_files()

        if self.opts.id or self.opts.name:
            # we are adding / editing a group
            group = self.find_group(group_id=self.opts.id, name=self.opts.name)
            if group is None:
                # create a new group
                if self.opts.remove:
                    raise dnf.exceptions.Error(
                        _("Can't remove packages from non-existent group"))
                group = libcomps.Group()
                if self.opts.id:
                    group.id = self.opts.id
                    group.name = self.opts.id
                elif self.opts.name:
                    group_id = text_to_id(self.opts.name)
                    if self.find_group(group_id=group_id, name=None):
                        raise dnf.cli.CliError(
                            _("Group id '{}' generated from '{}' is duplicit. "
                              "Please specify group id using --id.").format(
                                  group_id, self.opts.name))
                    group.id = group_id
                self.comps.groups.append(group)
            self.edit_group(group)

        self.save_output_files()
        if self.opts.print or (not self.opts.save):
            print(self.comps.xml_str(xml_options=COMPS_XML_OPTIONS))
Esempio n. 4
0
    def test_group_name(self):
        # dnf.comps.Group.name
        libcomps_group = libcomps.Group("id", "name", "description")
        group = dnf.comps.Group(iobj=libcomps_group,
                                langs=None,
                                pkg_factory=None)

        self.assertHasAttr(group, "name")
        self.assertHasType(group.name, str)
Esempio n. 5
0
    def test_group_ui_description(self):
        # dnf.comps.Group.ui_description
        libcomps_group = libcomps.Group("id", "name", "description")
        langs = MockLangs()
        group = dnf.comps.Group(iobj=libcomps_group,
                                langs=langs,
                                pkg_factory=None)

        self.assertHasAttr(group, "ui_description")
        self.assertHasType(group.ui_description, str)
Esempio n. 6
0
 def test_group_packages_iter(self):
     # dnf.comps.Group.packages_iter
     libcomps_group = libcomps.Group("id", "name", "description")
     group = dnf.comps.Group(libcomps_group, None, lambda x: x)
     group.packages_iter()
Esempio n. 7
0
 def test_group_init(self):
     libcomps_group = libcomps.Group("id", "name", "description")
     _ = dnf.comps.Group(iobj=libcomps_group, langs=None, pkg_factory=None)