diff options
author | fuzzyray <fuzzyray@gentoo.org> | 2010-03-24 15:21:58 +0000 |
---|---|---|
committer | fuzzyray <fuzzyray@gentoo.org> | 2010-03-24 15:21:58 +0000 |
commit | db09a0e43e2e1cf98f0d789f651a1816a46dcba7 (patch) | |
tree | 190142ffd40988d90ab8f5789500be5290e91088 /pym/gentoolkit/helpers.py | |
parent | Update to genscripts rev 382. This has more fixes for py3k and the modular re... (diff) | |
download | gentoolkit-db09a0e43e2e1cf98f0d789f651a1816a46dcba7.tar.gz gentoolkit-db09a0e43e2e1cf98f0d789f651a1816a46dcba7.tar.bz2 gentoolkit-db09a0e43e2e1cf98f0d789f651a1816a46dcba7.zip |
Merge genscripts rev 406
svn path=/trunk/gentoolkit/; revision=756
Diffstat (limited to 'pym/gentoolkit/helpers.py')
-rw-r--r-- | pym/gentoolkit/helpers.py | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py index 6888619..c1c6788 100644 --- a/pym/gentoolkit/helpers.py +++ b/pym/gentoolkit/helpers.py @@ -10,8 +10,6 @@ the query module, where they are called as: Query('portage').find_*(). """ -from __future__ import print_function - __all__ = ( 'ChangeLog', 'FileOwner', @@ -19,7 +17,6 @@ __all__ = ( 'get_installed_cpvs', 'get_uninstalled_cpvs', 'uniqify', - 'walk' ) __docformat__ = 'epytext' @@ -27,14 +24,13 @@ __docformat__ = 'epytext' # Imports # ======= +import os import sys import re import codecs from functools import partial from itertools import chain -from portage import os, _unicode_decode, _encodings - from gentoolkit import pprinter as pp from gentoolkit import errors from gentoolkit.atom import Atom @@ -437,20 +433,16 @@ def get_installed_cpvs(predicate=None): def print_file(path): """Display the contents of a file.""" - out = sys.stdout - if hasattr(out, "buffer"): - out = out.buffer - with open(path, "rb") as open_file: lines = open_file.read() - print(lines.strip(), file = out) + pp.uprint(lines.strip()) -def print_sequence(seq, file = sys.stdout): +def print_sequence(seq): """Print every item of a sequence.""" for item in seq: - print(item, file = file) + pp.uprint(item) def uniqify(seq, preserve_order=True): @@ -464,20 +456,4 @@ def uniqify(seq, preserve_order=True): return result - -def walk(top, topdown = True, onerror = None, followlinks = False): - """Variant of os.walk that always returns unicode filenames""" - for root, dirs, files in os.walk(top, topdown, onerror, followlinks): - root = _unicode_decode(root, _encodings["fs"], errors = "strict") - dirs = [ - _unicode_decode(x, _encodings["fs"], errors = "strict") - for x in dirs - ] - files = [ - _unicode_decode(x, _encodings["fs"], errors = "strict") - for x in files - ] - # XXX: in contrast with os.walk we ignore modifications to dirs here - yield root, dirs, files - # vim: set ts=4 sw=4 tw=79: |