Fix StringIO imports so that 2to3 can handle them. Also, replace shlex +
authorZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:00:59 +0000 (06:00 -0000)
committerZac Medico <zmedico@gentoo.org>
Wed, 11 Mar 2009 06:00:59 +0000 (06:00 -0000)
StringIO usage with shlex.split() where appropriate. (trunk r12662)

svn path=/main/branches/2.1.6/; revision=12925

bin/repoman
pym/_emerge/__init__.py
pym/portage/__init__.py
pym/portage/getbinpkg.py
pym/portage/util.py

index 7b5daf353cb263e86763ee2cdfd73b179f982af8..4c242c04508bb497c9ad8a20b07f91779464638b 100755 (executable)
@@ -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()):
index 2b80a41d58998d56e4da5c1090a7bc390e7ee24a..9737952b35c65d425531e2bcae6f90b79b23e1d9 100644 (file)
@@ -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 = [
@@ -9752,8 +9752,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)
@@ -12281,7 +12281,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([
@@ -12306,12 +12305,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 " + \
@@ -12389,11 +12384,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:
index 2a2a04dc79ff596ac98247d58fafa3675a53879c..a97834f48502d4daf58d7a170ee6d95a7d9ae77c 100644 (file)
@@ -4069,10 +4069,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:
 
index f657c67a1a11fc9b74bbf6862afbfca0f66a4abe..bb3911a6b57e521f723e54591cb655c86c49b7e8 100644 (file)
@@ -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(),
index 54df381922d74dba825dd4557f245ef2904aec9f..eaab1bf4a1bb474cee0bed671f314d174756f567 100644 (file)
@@ -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):
        """