Ejemplo n.º 1
0
def package_action(pkg):
    for p in package_data.values():
        if rcd_util.get_package_key(pkg) == rcd_util.get_package_key(
                p["__package"]):
            return p.get("action", NO_ACTION)

    return NO_ACTION
Ejemplo n.º 2
0
    def filter_duplicates(self, patches):
        # Find System packages
        in_system = {}
        for p in patches:
            if rcd_util.is_system_package(p):
                key = rcd_util.get_package_key(p)
                in_system[key] = 1

        # Remove instelled Channel packages
        for p in patches:
            if not rcd_util.is_system_package(p):
                key = rcd_util.get_package_key(p)
                if in_system.has_key(key):
                    patches.remove(p)

        return patches
Ejemplo n.º 3
0
def show_package_info(pkg, parent=None):

    key = rcd_util.get_package_key(pkg)
    if package_infos.has_key(key):
        dialog = package_infos[key]
        dialog.present()
        return

    book = PackageBook()
    book.set_tab_pos(gtk.POS_TOP)
    book.add_page(red_packagepage_info.PackagePage_Info())
    if rcd_util.get_package_type(pkg) == rcd_util.PACKAGE_TYPE_PACKAGE:
        book.add_page(red_packagepage.PackagePage_History())
        book.add_page(red_packagepage_deps.PackagePage_Deps())

    book.set_package(pkg)

    title = _("Package Information") + ": " + pkg["name"]
    dialog = gtk.Dialog(title, parent=parent)
    dialog.set_default_size(450, 350)
    button = dialog.add_button(gtk.STOCK_CLOSE, 0)
    # grab_default() is not sufficient here.
    button.grab_focus()
    dialog.connect("response", lambda d, code: d.destroy())

    dialog.vbox.add(book)

    def destroy_cb(dialog, key):
        del package_infos[key]

    package_infos[key] = dialog
    dialog.connect("destroy", destroy_cb, key)

    book.show_all()
    dialog.show_all()
Ejemplo n.º 4
0
def set(pkg, key, value):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.setdefault(pkg_key, {"__package": pkg})
    old_value = dict.get(key)
    if old_value != value:
        dict[key] = value
        signal_listeners(pkg, key, value, old_value)
Ejemplo n.º 5
0
def set(pkg, key, value):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.setdefault(pkg_key, {"__package": pkg})
    old_value = dict.get(key)
    if old_value != value:
        dict[key] = value
        signal_listeners(pkg, key, value, old_value)
Ejemplo n.º 6
0
def get(pkg, key, default=__no_default):
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if not dict:
        raise UnknownPackage, pkg
    if default == __no_default:
        if not dict.has_key(key):
            raise UnknownKey, key, pkg
    return dict.get(key, default)
Ejemplo n.º 7
0
def set_action(pkg, action):
    key = rcd_util.get_package_key(pkg)
    name = pkg["name"]
    for xkey, x in package_data.iteritems():
        if xkey != key:
            p = x["__package"]
            if p["name"] == name:
                set(p, "action", NO_ACTION)
    set(pkg, "action", action)
Ejemplo n.º 8
0
def get(pkg, key, default=__no_default):
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if not dict:
        raise UnknownPackage, pkg
    if default == __no_default:
        if not dict.has_key(key):
            raise UnknownKey, key, pkg
    return dict.get(key, default)
Ejemplo n.º 9
0
def set_action(pkg, action):
    key = rcd_util.get_package_key(pkg)
    name = pkg["name"]
    for xkey, x in package_data.iteritems():
        if xkey != key:
            p = x["__package"]
            if p["name"] == name:
                set(p, "action", NO_ACTION)
    set(pkg, "action", action)
Ejemplo n.º 10
0
    def do_changed(self):
        operator, args = red_listmodel.ListModel.do_changed(self)

        if operator:
            self.__package_keys = {}
            for i in xrange(self.length()):
                p = self.get_list_item(i)
                key = rcd_util.get_package_key(p)
                indices = self.__package_keys.setdefault(key, [])
                indices.append(i)
Ejemplo n.º 11
0
def clear(pkg, key):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if dict and dict.has_key(key):
        old_value = dict[key]
        del dict[key]
        # Remove package from list if threre's no more keys than "__package"
        if len(dict.keys()) <= 1:
            del package_data[pkg_key]
        signal_listeners(pkg, key, None, old_value)
Ejemplo n.º 12
0
def clear(pkg, key):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if dict and dict.has_key(key):
        old_value = dict[key]
        del dict[key]
        # Remove package from list if threre's no more keys than "__package"
        if len(dict.keys()) <= 1:
            del package_data[pkg_key]
        signal_listeners(pkg, key, None, old_value)
Ejemplo n.º 13
0
 def changed_one_by_package(self, pkg):
     key = rcd_util.get_package_key(pkg)
     indices = self.__package_keys.get(key, [])
     for i in indices:
         self.changed_one(i)
Ejemplo n.º 14
0
def package_action(pkg):
    for p in package_data.values():
        if rcd_util.get_package_key(pkg) == rcd_util.get_package_key(p["__package"]):
            return p.get("action", NO_ACTION)

    return NO_ACTION
Ejemplo n.º 15
0
def keys(pkg):
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if not dict:
        return None
    return filter(lambda x:x[0:2] != "__", dict.keys())
Ejemplo n.º 16
0
def del_package(pkg):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    if package_data.has_key(pkg_key):
        del package_data[pkg_key]
        signal_listeners()
Ejemplo n.º 17
0
def has_package(pkg):
    pkg_key = rcd_util.get_package_key(pkg)
    return package_data.has_key(pkg_key)
Ejemplo n.º 18
0
def has_package(pkg):
    pkg_key = rcd_util.get_package_key(pkg)
    return package_data.has_key(pkg_key)
Ejemplo n.º 19
0
def keys(pkg):
    pkg_key = rcd_util.get_package_key(pkg)
    dict = package_data.get(pkg_key)
    if not dict:
        return None
    return filter(lambda x: x[0:2] != "__", dict.keys())
Ejemplo n.º 20
0
def del_package(pkg):
    global package_data
    pkg_key = rcd_util.get_package_key(pkg)
    if package_data.has_key(pkg_key):
        del package_data[pkg_key]
        signal_listeners()