OSDN Git Service

fix debug_out, error_out, warn_out method
authort.moriyama <t.moriyama@users.sourceforge.jp>
Fri, 14 Jun 2013 13:08:44 +0000 (22:08 +0900)
committert.moriyama <t.moriyama@users.sourceforge.jp>
Fri, 14 Jun 2013 13:08:44 +0000 (22:08 +0900)
linkpair/utils/common.py

index 5606fc1..9aad16c 100755 (executable)
@@ -2,15 +2,17 @@
 # -*- coding: utf-8 -*-
 #
 
-__version__ = '1.1'
-
+from __future__ import print_function
 import re
-
+import sys
 
 class CommonUtils(object):
 
     def __init__(self):
         self._tmp_stack = []
+        
+    def set_opts(self, opts):
+        self._opts = opts
 
     def d_push(self, x):
         self._tmp_stack.append(x)
@@ -20,15 +22,21 @@ class CommonUtils(object):
         return self._tmp_stack.pop()
 
     def verbose_out(self, msg):
-        if self.opts.verbose is True:
-            print msg
+        if self._opts.verbose is True:
+            printr("[verbose]: " + msg, file=sys.stderr)
 
     def debug_out(self, msg):
-        if self.opts.debug is True:
-            print "debug: " + msg
+        if self._opts.debug is True:
+            print("[debug]: " + msg, file=sys.stderr)
+
+    def warn_out(self, msg):
+        print("[warn]: " + msg, file=sys.stderr)
+
+    def error_out(self, msg):
+        print("[error]: " + msg, file=sys.stderr)
 
     def message_out(self, msg):
-        print msg
+        print(msg)
 
     def parse_remote_desc(self, remote_desc):
         ssh_username = ""