Fix StringIO imports so that 2to3 can handle them. Also, replace shlex +
authorZac Medico <zmedico@gentoo.org>
Fri, 20 Feb 2009 07:16:16 +0000 (07:16 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 20 Feb 2009 07:16:16 +0000 (07:16 -0000)
StringIO usage with shlex.split() where appropriate.

svn path=/main/trunk/; revision=12662

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

index 46d5f452e43902c170026c6b6cb0087ab9989c43..eaa03f749029a4f1372529c44870275a82e67a5d 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 63a99201a858f2cb2687ea273a6ed8c567680344..7505deda0f1e26e2bc7e1307188f7d1e505d6181 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 = [
@@ -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:
index 621daa7bee1bbfe00aa3210d0c7de7f848a8bc46..3be6e651f3c7ecc04f7dac9b1f52b4aeff962f5b 100644 (file)
@@ -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:
 
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):
        """