[zypp-devel] python: ResPool object is unsubscriptable
Hi, I would be nice if ResPool objects would be subscriptable (dictionaries). For example it'd be very convenient to have an access to pool items like this: Z = zypp.ZYppFactory_instance().getZYpp() ... p = Z.pool() print p[package_name].isInstalled() where package_name is a key name (pool item name). Right now the only way I could find to do this is: for item in Z.pool(): if item.name() == pkg_name: print item.status().isInstalled() which makes code a bit bloated. -- Regards, Nikolay Derkach -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Nikolay Derkach wrote:
Hi,
I would be nice if ResPool objects would be subscriptable (dictionaries). For example it'd be very convenient to have an access to pool items like this:
Z = zypp.ZYppFactory_instance().getZYpp()
...
p = Z.pool() print p[package_name].isInstalled()
where package_name is a key name (pool item name).
But there can be multiple PoolItems with the same name (different versions, different kinds)... Such an interface could be provided, but it would still not point to a single PoolItem, but rather a set.
Right now the only way I could find to do this is:
for item in Z.pool(): if item.name() == pkg_name: print item.status().isInstalled()
which makes code a bit bloated.
Better use the byName or byIdent iterators, they use indices. cheers, jano -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Mon, Sep 08, Jano Kupec wrote:
Nikolay Derkach wrote:
Hi,
I would be nice if ResPool objects would be subscriptable (dictionaries). For example it'd be very convenient to have an access to pool items like this:
Z = zypp.ZYppFactory_instance().getZYpp()
...
p = Z.pool() print p[package_name].isInstalled()
where package_name is a key name (pool item name).
But there can be multiple PoolItems with the same name (different versions, different kinds)... Such an interface could be provided, but it would still not point to a single PoolItem, but rather a set.
Right now the only way I could find to do this is:
for item in Z.pool(): if item.name() == pkg_name: print item.status().isInstalled()
which makes code a bit bloated.
Better use the byName or byIdent iterators, they use indices.
Hmm. I guess the Selectable is missing in the bindings :( The Selectable groups all PoolItems with the same name and makes them availabe to you. You see installed and available versions and it supports status manipulation. And Selectable would be subscriptable. -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
Michael Andres wrote:
On Mon, Sep 08, Jano Kupec wrote:
Nikolay Derkach wrote:
Hi,
I would be nice if ResPool objects would be subscriptable (dictionaries). For example it'd be very convenient to have an access to pool items like this:
Z = zypp.ZYppFactory_instance().getZYpp()
...
p = Z.pool() print p[package_name].isInstalled()
where package_name is a key name (pool item name). But there can be multiple PoolItems with the same name (different versions, different kinds)... Such an interface could be provided, but it would still not point to a single PoolItem, but rather a set.
Right now the only way I could find to do this is:
for item in Z.pool(): if item.name() == pkg_name: print item.status().isInstalled()
which makes code a bit bloated. Better use the byName or byIdent iterators, they use indices.
Hmm. I guess the Selectable is missing in the bindings :(
The Selectable groups all PoolItems with the same name and makes them availabe to you. You see installed and available versions and it supports status manipulation.
And Selectable would be subscriptable.
What about the kind? j. -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
On Mon, Sep 08, Jan Kupec wrote:
Michael Andres wrote:
On Mon, Sep 08, Jano Kupec wrote:
Nikolay Derkach wrote:
Hi,
I would be nice if ResPool objects would be subscriptable (dictionaries). For example it'd be very convenient to have an access to pool items like this:
Z = zypp.ZYppFactory_instance().getZYpp()
...
p = Z.pool() print p[package_name].isInstalled()
where package_name is a key name (pool item name). But there can be multiple PoolItems with the same name (different versions, different kinds)... Such an interface could be provided, but it would still not point to a single PoolItem, but rather a set.
Right now the only way I could find to do this is:
for item in Z.pool(): if item.name() == pkg_name: print item.status().isInstalled()
which makes code a bit bloated. Better use the byName or byIdent iterators, they use indices.
Hmm. I guess the Selectable is missing in the bindings :(
The Selectable groups all PoolItems with the same name and makes them availabe to you. You see installed and available versions and it supports status manipulation.
And Selectable would be subscriptable.
What about the kind?
ByIdent. That's IMO fine as packages do not need a namespace prefix. package: selectable["zypper"] selectable["package::zypper"] vs. selectable["patch:zypper"] selectable["srcpackage::zypper"] I'd like to integrate the Selectable into the ResPool, because we want to get rid of direct status manipulation of PoolItems. Selectable should beome the primary interface for status maipulation. Selectable "zypper" | +-> list of installed zypper PoolItems (usually one) | +-> list of available zypper PoolItems (from all repositories). | +-> Status (keep|install|delete|update) -- cu, Michael Andres +------------------------------------------------------------------+ Key fingerprint = 2DFA 5D73 18B1 E7EF A862 27AC 3FB8 9E3A 27C6 B0E4 +------------------------------------------------------------------+ Michael Andres YaST Development ma@novell.com SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG Nuernberg) Maxfeldstrasse 5, D-90409 Nuernberg, Germany, ++49 (0)911 - 740 53-0 +------------------------------------------------------------------+ -- To unsubscribe, e-mail: zypp-devel+unsubscribe@opensuse.org For additional commands, e-mail: zypp-devel+help@opensuse.org
participants (4)
-
Jan Kupec
-
Jano Kupec
-
Michael Andres
-
Nikolay Derkach