Browse Source

changed the use of raw_input and items() in dictionary for python 3 compatibility

Helmut Pozimski 10 năm trước cách đây
mục cha
commit
4de55af210
1 tập tin đã thay đổi với 9 bổ sung4 xóa
  1. 9 4
      lib_stov/configuration.py

+ 9 - 4
lib_stov/configuration.py

@@ -20,6 +20,7 @@ from __future__ import print_function
 
 import os
 import subprocess
+import sys
 
 from lib_stov import stov_exceptions
 
@@ -95,7 +96,7 @@ class conf(object):
         except IOError:
             raise stov_exceptions.ConfigFileWriteErrorException()
         else:
-            for key in self.values.iterkeys():
+            for key in self.values.items():
                 configfile.write(key.upper() + "=" + self.values[key] +
                                  "\n")
             configfile.close()
@@ -217,9 +218,13 @@ class conf(object):
                 "displayed in brackets.\n"
                 "Please specify now :\n"))
         for value in self.__explanations:
-            print(self.__explanations[value] + " [" + self.values[value] + "]:"
-                                                                           " ")
-            user_input = raw_input()
+            print(self.__explanations[value] + " [" + self.values[value] +
+                  "]:" +
+                  " ")
+            if sys.version_info >= (3, 0):
+                user_input = input()
+            else:
+                user_input = raw_input()
             if user_input != "":
                 self.values[value] = user_input
         self.dbpath = str(os.environ['HOME']) + "/.stov/" + \