diff options
author | Michael Andres <ma@suse.de> | 2007-12-04 13:22:36 +0000 |
---|---|---|
committer | Michael Andres <ma@suse.de> | 2007-12-04 13:22:36 +0000 |
commit | d0115179f9a9bcae213d9c7f0017e29a95e291af (patch) | |
tree | dfc70999b64609ea7b3df8569872c4f61d44d46b /examples/python | |
parent | f05bab0a069933f8e559cf8649376e1f604ad2da (diff) | |
download | libzypp-bindings-d0115179f9a9bcae213d9c7f0017e29a95e291af.tar.gz libzypp-bindings-d0115179f9a9bcae213d9c7f0017e29a95e291af.tar.bz2 libzypp-bindings-d0115179f9a9bcae213d9c7f0017e29a95e291af.zip |
Added python examples how to list installed/available/all resolvables
Diffstat (limited to 'examples/python')
-rwxr-xr-x | examples/python/list_available_resolvables.py | 25 | ||||
-rwxr-xr-x | examples/python/list_installed_resolvables.py | 14 | ||||
-rwxr-xr-x | examples/python/list_resolvables.py | 33 |
3 files changed, 72 insertions, 0 deletions
diff --git a/examples/python/list_available_resolvables.py b/examples/python/list_available_resolvables.py new file mode 100755 index 0000000..f282773 --- /dev/null +++ b/examples/python/list_available_resolvables.py @@ -0,0 +1,25 @@ +#! /usr/bin/python +import zypp + +Z = zypp.ZYppFactory_instance().getZYpp() + +repoManager = zypp.RepoManager() +repos = repoManager.knownRepositories() + +for repo in repos: + if not repo.enabled(): + continue + if not repoManager.isCached( repo ): + repoManager.buildCache( repo ) + + Z.addResolvables( repoManager.createFromCache( repo ).resolvables() ) + + +print "Available items: %d" % ( Z.pool().size() ) + +for item in Z.pool(): + print "* %s:%s-%s.%s\t(%s)" % ( item.resolvable().kindToS(), + item.resolvable().name(), + item.resolvable().edition(), + item.resolvable().arch(), + item.resolvable().repository().info().alias() ) diff --git a/examples/python/list_installed_resolvables.py b/examples/python/list_installed_resolvables.py new file mode 100755 index 0000000..6182b86 --- /dev/null +++ b/examples/python/list_installed_resolvables.py @@ -0,0 +1,14 @@ +#! /usr/bin/python +import zypp + +Z = zypp.ZYppFactory_instance().getZYpp() +Z.initializeTarget( zypp.Pathname("/") ) +Z.addResolvables( Z.target().resolvables(), True ); + +print "Installed items: %d" % ( Z.pool().size() ) + +for item in Z.pool(): + print "i %s:%s-%s.%s" % ( item.resolvable().kindToS(), + item.resolvable().name(), + item.resolvable().edition(), + item.resolvable().arch() ) diff --git a/examples/python/list_resolvables.py b/examples/python/list_resolvables.py new file mode 100755 index 0000000..b484cc8 --- /dev/null +++ b/examples/python/list_resolvables.py @@ -0,0 +1,33 @@ +#! /usr/bin/python +import zypp + +Z = zypp.ZYppFactory_instance().getZYpp() + +Z.initializeTarget( zypp.Pathname("/") ) +Z.addResolvables( Z.target().resolvables(), True ); + +repoManager = zypp.RepoManager() +repos = repoManager.knownRepositories() + +for repo in repos: + if not repo.enabled(): + continue + if not repoManager.isCached( repo ): + repoManager.buildCache( repo ) + + Z.addResolvables( repoManager.createFromCache( repo ).resolvables() ) + + +print "Items: %d" % ( Z.pool().size() ) + +for item in Z.pool(): + if item.status().isInstalled(): + t = "i" + else: + t = "*" + print "%s %s:%s-%s.%s\t(%s)" % ( t, + item.resolvable().kindToS(), + item.resolvable().name(), + item.resolvable().edition(), + item.resolvable().arch(), + item.resolvable().repository().info().alias() ) |