Use stdout.write() instead of "print", for py3k compat.
authorZac Medico <zmedico@gentoo.org>
Thu, 3 Jul 2008 03:09:21 +0000 (03:09 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 3 Jul 2008 03:09:21 +0000 (03:09 -0000)
svn path=/main/trunk/; revision=10897

pym/portage/output.py

index 45def2b384c23fac24f15397b5ecd9f7e0ce0547..35dba7f0d8cb08ce16a1b2daeeb58df6e8e86af7 100644 (file)
@@ -461,8 +461,10 @@ class EOutput(object):
                                        self.ewarn(msg[0])
                if self.__last_e_cmd != "ebegin":
                        self.__last_e_len = 0
-               print "%*s%s" % ((self.term_columns - self.__last_e_len - 6), "", status_brackets)
-               sys.stdout.flush()
+               out = sys.stdout
+               out.write("%*s%s\n" % \
+                       ((self.term_columns - self.__last_e_len - 6), "", status_brackets))
+               out.flush()
 
        def ebegin(self, msg):
                """
@@ -501,10 +503,12 @@ class EOutput(object):
                @param msg: A very brief (shorter than one line) error message.
                @type msg: StringType
                """
+               out = sys.stdout
                if not self.quiet:
-                       if self.__last_e_cmd == "ebegin": print
-                       print colorize("BAD", " * ") + msg
-                       sys.stdout.flush()
+                       if self.__last_e_cmd == "ebegin":
+                               out.write("\n")
+                       out.write(colorize("BAD", " * ") + msg + "\n")
+                       out.flush()
                self.__last_e_cmd = "eerror"
 
        def einfo(self, msg):
@@ -514,10 +518,12 @@ class EOutput(object):
                @param msg: A very brief (shorter than one line) informative message.
                @type msg: StringType
                """
+               out = sys.stdout
                if not self.quiet:
-                       if self.__last_e_cmd == "ebegin": print
-                       print colorize("GOOD", " * ") + msg
-                       sys.stdout.flush()
+                       if self.__last_e_cmd == "ebegin":
+                               out.write("\n")
+                       out.write(colorize("GOOD", " * ") + msg + "\n")
+                       out.flush()
                self.__last_e_cmd = "einfo"
 
        def einfon(self, msg):
@@ -527,10 +533,12 @@ class EOutput(object):
                @param msg: A very brief (shorter than one line) informative message.
                @type msg: StringType
                """
+               out = sys.stdout
                if not self.quiet:
-                       if self.__last_e_cmd == "ebegin": print
-                       print colorize("GOOD", " * ") + msg ,
-                       sys.stdout.flush()
+                       if self.__last_e_cmd == "ebegin":
+                               out.write("\n")
+                       out.write(colorize("GOOD", " * ") + msg)
+                       out.flush()
                self.__last_e_cmd = "einfon"
 
        def ewarn(self, msg):
@@ -540,10 +548,12 @@ class EOutput(object):
                @param msg: A very brief (shorter than one line) warning message.
                @type msg: StringType
                """
+               out = sys.stdout
                if not self.quiet:
-                       if self.__last_e_cmd == "ebegin": print
-                       print colorize("WARN", " * ") + msg
-                       sys.stdout.flush()
+                       if self.__last_e_cmd == "ebegin":
+                               out.write("\n")
+                       out.write(colorize("WARN", " * ") + msg + "\n")
+                       out.flush()
                self.__last_e_cmd = "ewarn"
 
        def ewend(self, errno, *msg):