diff options
Diffstat (limited to 'examples/python/SimpleWalkthrough.py')
-rw-r--r-- | examples/python/SimpleWalkthrough.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/examples/python/SimpleWalkthrough.py b/examples/python/SimpleWalkthrough.py index a1b6d94..e14cc87 100644 --- a/examples/python/SimpleWalkthrough.py +++ b/examples/python/SimpleWalkthrough.py @@ -3,43 +3,43 @@ import zypp # ======================================================================================== def poolInstall( Z, capstr ): - print "Request: install %s" % capstr + print("Request: install %s" % capstr) Z.resolver().addRequire( zypp.Capability( capstr ) ) def poolRemove( Z, capstr ): - print "Request: delete %s" % capstr + print("Request: delete %s" % capstr) Z.resolver().addConflict( zypp.Capability( capstr ) ) def poolPrintTransaction( Z ): todo = Z.pool().getTransaction() for item in todo._toDelete: - print '-- %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() ) + print('-- %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() )) for item in todo._toInstall: - print '++ %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() ) + print('++ %s | %s-%s | %s' % (item.repoInfo().alias(), item.name(), item.edition(), item.status() )) def poolResolve( Z ): - print "Resolve pool:" + print("Resolve pool:") while not Z.resolver().resolvePool(): # Print _all_ problems and possible solutions: problems = Z.resolver().problems() pn = 0 for problem in problems: pn += 1 - print "Problem %d:" % pn - print "==============================" - print problem.description() + print("Problem %d:" % pn) + print("==============================") + print(problem.description()) if problem.details(): - print problem.details() - print "------------------------------" + print(problem.details()) + print("------------------------------") sn = 0 for solution in problem.solutions(): sn += 1 - print "Solution %d.%d:" % ( pn, sn ) - print solution.description() + print("Solution %d.%d:" % ( pn, sn )) + print(solution.description()) if solution.details(): - print solution.details() - print "==============================" - print + print(solution.details()) + print("==============================") + print() # Faked user interaction: stupidly pick all 1st solutions (don't do this in real life!) # @@ -54,26 +54,26 @@ def poolResolve( Z ): sn = 0 for solution in problem.solutions(): sn += 1 - print "Stupidly pick solution %d.%d" % ( pn, sn ) + print("Stupidly pick solution %d.%d" % ( pn, sn )) pickedSolutions.push_back( solution ) break # Apply picked solutions: Z.resolver().applySolutions( pickedSolutions ) # - print "Example stops here instead of starting a new iteration..." - print + print("Example stops here instead of starting a new iteration...") + print() raise BaseException("Solver Error") poolPrintTransaction( Z ) - print "[done]" + print("[done]") def poolUpdate( Z ): # In contrary to - print "Update pool:" + print("Update pool:") Z.resolver().doUpdate() poolPrintTransaction( Z ) - print "[done]" + print("[done]") # ======================================================================================== Z = zypp.ZYppFactory_instance().getZYpp() @@ -95,13 +95,13 @@ for repo in repoManager.knownRepositories(): # Now all installed and available items are in the pool: # -print "Known items: %d" % ( Z.pool().size() ) +print("Known items: %d" % ( Z.pool().size() )) if True: # Iterate the pool to query items. PoolItems are not just packages # but also patterns, patches, products, ... # PoolItem provides the common attributes and status. For specific # attibutes cast the item inot the specific kind. - print "Printing just the Products..." + print("Printing just the Products...") for item in Z.pool(): if not zypp.isKindProduct( item ): continue @@ -110,18 +110,18 @@ if True: t = "i" else: t = "*" - print "%s %s:%s-%s.%s\t(%s)" % ( t, + print("%s %s:%s-%s.%s\t(%s)" % ( t, item.kind(), item.name(), item.edition(), item.arch(), - item.repoInfo().alias() ) + item.repoInfo().alias() )) # How to access e.g. product specific attributes: if zypp.isKindProduct( item ): prod = zypp.asKindProduct( item ) - print " %s (%s)" % ( prod.shortName(), prod.flavor() ) - print + print(" %s (%s)" % ( prod.shortName(), prod.flavor() )) + print() # Building and resolving a transaction: # @@ -144,4 +144,4 @@ policy.syncPoolAfterCommit( False ) policy.dryRun( True ) result = Z.commit( policy ) -print result +print(result) |