aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gmail.com>2015-08-23 14:25:49 -0400
committerTim Harder <radhermit@gmail.com>2015-08-23 14:26:20 -0400
commit51f491a3d54a3dadb90398178465bd6696ff14dd (patch)
treee4f0bdadf5116b43be1e34a854faf4e82cb61650 /examples
parentpebuild: check if phase is undefined on buildable object (diff)
downloadpkgcore-51f491a3d54a3dadb90398178465bd6696ff14dd.tar.gz
pkgcore-51f491a3d54a3dadb90398178465bd6696ff14dd.tar.bz2
pkgcore-51f491a3d54a3dadb90398178465bd6696ff14dd.zip
examples: fix API examples and use print() from __future__
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/changed_use.py9
-rwxr-xr-xexamples/pclean.py11
-rwxr-xr-xexamples/pkg_info.py11
-rwxr-xr-xexamples/repo_list.py10
4 files changed, 22 insertions, 19 deletions
diff --git a/examples/changed_use.py b/examples/changed_use.py
index 8ae7f21b4..9e099909f 100755
--- a/examples/changed_use.py
+++ b/examples/changed_use.py
@@ -2,6 +2,8 @@
# Copyright 2007 Charlie Shepherd
+from __future__ import print_function
+
from operator import attrgetter
import sys
@@ -9,11 +11,10 @@ try:
from pkgcore.util import commandline
from pkgcore.restrictions.boolean import OrRestriction
except ImportError:
- print >> sys.stderr, 'Cannot import pkgcore!'
- print >> sys.stderr, 'Verify it is properly installed and/or ' \
- 'PYTHONPATH is set correctly.'
+ print('Cannot import pkgcore!', file=sys.stderr)
+ print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr)
if '--debug' not in sys.argv:
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ print('Add --debug to the commandline for a traceback.', file=sys.stderr)
else:
raise
sys.exit(1)
diff --git a/examples/pclean.py b/examples/pclean.py
index fb70faee7..ea6186ee1 100755
--- a/examples/pclean.py
+++ b/examples/pclean.py
@@ -3,6 +3,8 @@
# Copyright: 2007 Charlie Shepherd <masterdriverz@gmail.com>
# License: BSD/GPL-2
+from __future__ import print_function
+
from os.path import basename
import sys
@@ -15,14 +17,13 @@ try:
from pkgcore.restrictions.boolean import OrRestriction
from pkgcore.repository.multiplex import tree as multiplex_tree
from pkgcore.fetch import fetchable as fetchable_kls
- from pkgcore.chksum.errors import ParseChksumError
+ from pkgcore.package.errors import ParseChksumError
from pkgcore.util.repo_utils import get_virtual_repos
except ImportError:
- print >> sys.stderr, 'Cannot import pkgcore!'
- print >> sys.stderr, 'Verify it is properly installed and/or ' \
- 'PYTHONPATH is set correctly.'
+ print('Cannot import pkgcore!', file=sys.stderr)
+ print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr)
if '--debug' not in sys.argv:
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ print('Add --debug to the commandline for a traceback.', file=sys.stderr)
else:
raise
sys.exit(1)
diff --git a/examples/pkg_info.py b/examples/pkg_info.py
index b1ae338f1..acdca12c0 100755
--- a/examples/pkg_info.py
+++ b/examples/pkg_info.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+from __future__ import print_function
+
import itertools
import sys
@@ -7,11 +9,10 @@ try:
from pkgcore.util import commandline
from pkgcore.restrictions.boolean import OrRestriction
except ImportError:
- print >> sys.stderr, 'Cannot import pkgcore!'
- print >> sys.stderr, 'Verify it is properly installed and/or ' \
- 'PYTHONPATH is set correctly.'
+ print('Cannot import pkgcore!', file=sys.stderr)
+ print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr)
if '--debug' not in sys.argv:
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ print('Add --debug to the commandline for a traceback.', file=sys.stderr)
else:
raise
sys.exit(1)
@@ -26,7 +27,7 @@ class OptionParser(commandline.OptionParser):
def check_values(self, values, args):
values, args = commandline.OptionParser.check_values(
self, values, args)
- values.repo = values.config.get_default('domain').repos[1]
+ values.repo = values.config.get_default('domain').ebuild_repos
values.restrict = OrRestriction(*commandline.convert_to_restrict(args))
return values, ()
diff --git a/examples/repo_list.py b/examples/repo_list.py
index fcd0e252f..7de7d632d 100755
--- a/examples/repo_list.py
+++ b/examples/repo_list.py
@@ -1,18 +1,18 @@
#!/usr/bin/env python
-
# 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
except ImportError:
- print >> sys.stderr, 'Cannot import pkgcore!'
- print >> sys.stderr, 'Verify it is properly installed and/or ' \
- 'PYTHONPATH is set correctly.'
+ print('Cannot import pkgcore!', file=sys.stderr)
+ print('Verify it is properly installed and/or PYTHONPATH is set correctly.', file=sys.stderr)
if '--debug' not in sys.argv:
- print >> sys.stderr, 'Add --debug to the commandline for a traceback.'
+ print('Add --debug to the commandline for a traceback.', file=sys.stderr)
else:
raise
sys.exit(1)