diff options
author | Zac Medico <zmedico@gentoo.org> | 2009-02-20 07:16:16 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2009-02-20 07:16:16 +0000 |
commit | ff11bfce39a7b86c0d00ecc2d3909665c58dc85d (patch) | |
tree | 7fa47c05d6a69e6a096855a8c12ab76edf4e64ca | |
parent | fb05e64acc278e4395b4209e2219c404b3697252 (diff) | |
download | portage-ff11bfce39a7b86c0d00ecc2d3909665c58dc85d.tar.gz portage-ff11bfce39a7b86c0d00ecc2d3909665c58dc85d.tar.bz2 portage-ff11bfce39a7b86c0d00ecc2d3909665c58dc85d.zip |
Fix StringIO imports so that 2to3 can handle them. Also, replace shlex +
StringIO usage with shlex.split() where appropriate.
svn path=/main/trunk/; revision=12662
-rwxr-xr-x | bin/repoman | 6 | ||||
-rw-r--r-- | pym/_emerge/__init__.py | 24 | ||||
-rw-r--r-- | pym/portage/__init__.py | 7 | ||||
-rw-r--r-- | pym/portage/getbinpkg.py | 7 | ||||
-rw-r--r-- | pym/portage/util.py | 6 |
5 files changed, 20 insertions, 30 deletions
diff --git a/bin/repoman b/bin/repoman index 46d5f452e..eaa03f749 100755 --- a/bin/repoman +++ b/bin/repoman @@ -26,9 +26,9 @@ from itertools import chain, izip from stat import S_ISDIR, ST_CTIME try: - import cStringIO as StringIO + from cStringIO import StringIO except ImportError: - import StringIO + from StringIO import StringIO if not hasattr(__builtins__, "set"): from sets import Set as set @@ -1614,7 +1614,7 @@ if dofail or \ # in $EDITOR while the user creates a commit message. # Otherwise, the user would not be able to see this output # once the editor has taken over the screen. -qa_output = StringIO.StringIO() +qa_output = StringIO() style_file = ConsoleStyleFile(sys.stdout) if options.mode == 'commit' and \ (not commitmessage or not commitmessage.strip()): diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py index 63a99201a..7505deda0 100644 --- a/pym/_emerge/__init__.py +++ b/pym/_emerge/__init__.py @@ -63,9 +63,9 @@ except ImportError: import pickle try: - import cStringIO as StringIO + from cStringIO import StringIO except ImportError: - import StringIO + from StringIO import StringIO class stdout_spinner(object): scroll_msgs = [ @@ -9768,8 +9768,8 @@ class JobStatusDisplay(object): failed_str = str(self.failed) load_avg_str = self._load_avg_str() - color_output = StringIO.StringIO() - plain_output = StringIO.StringIO() + color_output = StringIO() + plain_output = StringIO() style_file = portage.output.ConsoleStyleFile(color_output) style_file.write_listener = plain_output style_writer = portage.output.StyleWriter(file=style_file, maxcol=9999) @@ -12457,7 +12457,6 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): mytimeout=180 rsync_opts = [] - import shlex, StringIO if settings["PORTAGE_RSYNC_OPTS"] == "": portage.writemsg("PORTAGE_RSYNC_OPTS empty or unset, using hardcoded defaults\n") rsync_opts.extend([ @@ -12482,12 +12481,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): # defaults. portage.writemsg("Using PORTAGE_RSYNC_OPTS instead of hardcoded defaults\n", 1) - lexer = shlex.shlex(StringIO.StringIO( - settings.get("PORTAGE_RSYNC_OPTS","")), posix=True) - lexer.whitespace_split = True - rsync_opts.extend(lexer) - del lexer - + rsync_opts.extend( + shlex.split(settings.get("PORTAGE_RSYNC_OPTS",""))) for opt in ("--recursive", "--times"): if opt not in rsync_opts: portage.writemsg(yellow("WARNING:") + " adding required option " + \ @@ -12565,11 +12560,8 @@ def action_sync(settings, trees, mtimedb, myopts, myaction): user_name="" updatecache_flg=True all_rsync_opts = set(rsync_opts) - lexer = shlex.shlex(StringIO.StringIO( - settings.get("PORTAGE_RSYNC_EXTRA_OPTS","")), posix=True) - lexer.whitespace_split = True - extra_rsync_opts = list(lexer) - del lexer + extra_rsync_opts = shlex.split( + settings.get("PORTAGE_RSYNC_EXTRA_OPTS","")) all_rsync_opts.update(extra_rsync_opts) family = socket.AF_INET if "-4" in all_rsync_opts or "--ipv4" in all_rsync_opts: diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 621daa7be..3be6e651f 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -4079,10 +4079,9 @@ def fetch(myuris, mysettings, listonly=0, fetchonly=0, locks_in_subdir=".locks", "URI": loc, "FILE": myfile } - import shlex, StringIO - lexer = shlex.shlex(StringIO.StringIO(locfetch), posix=True) - lexer.whitespace_split = True - myfetch = [varexpand(x, mydict=variables) for x in lexer] + import shlex + myfetch = shlex.split(locfetch) + myfetch = [varexpand(x, mydict=variables) for x in myfetch] myret = -1 try: diff --git a/pym/portage/getbinpkg.py b/pym/portage/getbinpkg.py index f657c67a1..bb3911a6b 100644 --- a/pym/portage/getbinpkg.py +++ b/pym/portage/getbinpkg.py @@ -400,12 +400,11 @@ def file_get(baseurl,dest,conn=None,fcmd=None): "URI": baseurl, "FILE": os.path.basename(baseurl) } - import shlex, StringIO + import shlex from portage.util import varexpand from portage.process import spawn - lexer = shlex.shlex(StringIO.StringIO(fcmd), posix=True) - lexer.whitespace_split = True - myfetch = [varexpand(x, mydict=variables) for x in lexer] + myfetch = shlex.split(fcmd) + myfetch = [varexpand(x, mydict=variables) for x in myfetch] fd_pipes= { 0:sys.stdin.fileno(), 1:sys.stdout.fileno(), diff --git a/pym/portage/util.py b/pym/portage/util.py index 54df38192..eaab1bf4a 100644 --- a/pym/portage/util.py +++ b/pym/portage/util.py @@ -23,9 +23,9 @@ except ImportError: import pickle try: - import cStringIO as StringIO + from cStringIO import StringIO except ImportError: - import StringIO + from StringIO import StringIO noiselimit = 0 @@ -500,7 +500,7 @@ class _tolerant_shlex(shlex.shlex): except EnvironmentError, e: writemsg("!!! Parse error in '%s': source command failed: %s\n" % \ (self.infile, str(e)), noiselevel=-1) - return (newfile, StringIO.StringIO()) + return (newfile, StringIO()) class _insert_newline_eof(ObjectProxy): """ |