aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2019-01-09 15:21:55 -0600
committerTim Harder <radhermit@gmail.com>2019-01-09 15:53:13 -0600
commit47de9f1bf1fb799be00197847d5f3c8623cf4b09 (patch)
treec1fef2a5842080fd7f7145697ab684d38fc35ca5 /examples
parentmake binpkg/vdb package wrapper classes top-level objects (diff)
downloadpkgcore-47de9f1bf1fb799be00197847d5f3c8623cf4b09.tar.gz
pkgcore-47de9f1bf1fb799be00197847d5f3c8623cf4b09.tar.bz2
pkgcore-47de9f1bf1fb799be00197847d5f3c8623cf4b09.zip
examples: update to work with past API changes
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/changed_use.py21
-rwxr-xr-xexamples/identify-installed-non-split-debug-pkgs.py43
-rwxr-xr-xexamples/pkg_info.py6
-rwxr-xr-xexamples/repo_list.py4
4 files changed, 33 insertions, 41 deletions
diff --git a/examples/changed_use.py b/examples/changed_use.py
index b952351d..f227bb8c 100755
--- a/examples/changed_use.py
+++ b/examples/changed_use.py
@@ -1,8 +1,6 @@
#!/usr/bin/env python3
# Copyright 2007 Charlie Shepherd
-from __future__ import print_function
-
from operator import attrgetter
import os
import sys
@@ -37,9 +35,10 @@ argparser.add_argument(
@argparser.bind_final_check
def check_args(parser, namespace):
domain = namespace.domain
- namespace.vdb = domain.vdb[0]
+ namespace.vdb = domain.all_installed_repos
if not namespace.repo:
- namespace.repo = domain.repos[1]
+ # fallback to default repo
+ namespace.repo = namespace.config.get_default('repo')
namespace.restrict = OrRestriction(
*commandline.convert_to_restrict(namespace.target))
@@ -50,21 +49,21 @@ def check_args(parser, namespace):
def main(options, out, err):
repo = options.repo
for built in options.vdb.itermatch(options.restrict):
- current = repo.match(built.versioned_atom)
+ current = repo.match(built.unversioned_atom)
if current:
current = current[0]
oldflags = built.iuse & built.use
newflags = current.iuse & built.use
if (newflags != oldflags) or (current.iuse ^ built.iuse):
changed_flags = (oldflags ^ newflags) | (current.iuse ^ built.iuse)
- if options.quiet:
- out.write(options.outputter(current))
- else:
+ if options.verbosity > 0:
out.write(
- "for package %s, %d flags have changed:\n\t%s" %
- (current.cpvstr, len(changed_flags), ' '.join(changed_flags)))
+ "package %s, %d flags have changed:\n\t%s" %
+ (current.unversioned_atom, len(changed_flags), ' '.join(changed_flags)))
+ else:
+ out.write(options.outputter(current))
else:
- if options.verbose:
+ if options.verbosity > 0:
out.write("%s is the same as it was before" % current.cpvstr)
if __name__ == '__main__':
diff --git a/examples/identify-installed-non-split-debug-pkgs.py b/examples/identify-installed-non-split-debug-pkgs.py
index 97f2e6b7..00e1ccac 100755
--- a/examples/identify-installed-non-split-debug-pkgs.py
+++ b/examples/identify-installed-non-split-debug-pkgs.py
@@ -6,28 +6,27 @@ from pkgcore.util.file_type import file_identifier
debug_paths = ["/usr/lib/debug"]
fi = file_identifier()
-vdbs = load_config().get_default("domain").vdb
-for repo in vdbs:
- for pkg in repo:
- contents = getattr(pkg, 'contents', ())
- if not contents:
- continue
- files = contents.iterfiles()
+vdbs = load_config().get_default("domain").all_installed_repos
+for pkg in sorted(vdbs):
+ contents = getattr(pkg, 'contents', ())
+ if not contents:
+ continue
+ files = contents.iterfiles()
- for obj in files:
- res = fi(obj.location)
- if res is None:
- # nonexistent file.
- continue
- if res.startswith("ELF "):
- break
- else:
- # no elf objects
+ for obj in files:
+ res = fi(obj.location)
+ if res is None:
+ # nonexistent file.
continue
+ if res.startswith("ELF "):
+ break
+ else:
+ # no elf objects
+ continue
- for path in debug_paths:
- if path in contents:
- break
- else:
- # no debug bits, but is elf.
- print "%s:%s" % (pkg.key, pkg.slot)
+ for path in debug_paths:
+ if path in contents:
+ break
+ else:
+ # no debug bits, but is elf.
+ print(f"{pkg.key}:{pkg.slot}")
diff --git a/examples/pkg_info.py b/examples/pkg_info.py
index 8eadc910..fba4efde 100755
--- a/examples/pkg_info.py
+++ b/examples/pkg_info.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python3
-from __future__ import print_function
-
import itertools
import sys
@@ -43,14 +41,12 @@ def main(options, out, err):
for pkg in pkgs:
out.write('%s::%s' % (pkg.cpvstr, pkg.repo.repo_id))
out.first_prefix = ""
- out.write()
item = 'maintainer'
values = t[1]
if values:
out.write(
"%s%s: %s" %
- (item.title(), 's'[len(values) == 1:], ', '.join((unicode(x) for x in values))))
- out.write()
+ (item.title(), 's'[len(values) == 1:], ', '.join(str(x) for x in values)))
out.write()
if __name__ == '__main__':
diff --git a/examples/repo_list.py b/examples/repo_list.py
index f9c92d57..002de9ab 100755
--- a/examples/repo_list.py
+++ b/examples/repo_list.py
@@ -1,13 +1,11 @@
#!/usr/bin/env python3
# Copyright 2007 Charlie Shepherd
-from __future__ import print_function
-
import sys
try:
from pkgcore.util import commandline
- from pkgcore.util.repo_utils import get_raw_repos, get_virtual_repos
+ from pkgcore.repository.util import get_raw_repos, get_virtual_repos
except ImportError:
print('Cannot import pkgcore!', file=sys.stderr)
print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr)