Repository: cekit/cekit
Pull request #213 (2018-04-18 13:35:42)

Removed python-future dependency


Patch:
diff --git a/cekit/builders/osbs.py b/cekit/builders/osbs.py
index 993c171..12bfef3 100644
--- a/cekit/builders/osbs.py
+++ b/cekit/builders/osbs.py
@@ -4,7 +4,6 @@ import shutil
 import subprocess
 import sys
 
-from builtins import input
 from cekit import tools
 from cekit.builder import Builder
 from cekit.errors import CekitError
@@ -129,7 +128,7 @@ class OSBSBuilder(Builder):
             else:
                 logger.info("No changes made to the code, committing skipped")
 
-            if decision("Do you want to build the image in OSBS?"):
+            if tools.decision("Do you want to build the image in OSBS?"):
                 build_type = "release" if self._release else "scratch"
                 logger.info("Executing %s container build in OSBS..." % build_type)
 
@@ -253,7 +252,7 @@ class DistGit(object):
             subprocess.call(["git", "status"])
             subprocess.call(["git", "show"])
 
-        if not (self.noninteractive or decision("Are you ok with the changes?")):
+        if not (self.noninteractive or tools.decision("Are you ok with the changes?")):
             logger.info("Executing bash in the repo directory. "
                         "After fixing the issues, exit the shell and Cekit will continue.")
             subprocess.call(["bash"], env={"PS1": "cekit $ ",
@@ -261,7 +260,7 @@ class DistGit(object):
                                            "HOME": os.getenv("HOME", "")})
 
     def push(self):
-        if self.noninteractive or decision("Do you want to push the commit?"):
+        if self.noninteractive or tools.decision("Do you want to push the commit?"):
             print("")
             logger.info("Pushing change to the upstream repository...")
             subprocess.check_output(["git", "push", "-q"])
@@ -271,12 +270,6 @@ class DistGit(object):
             sys.exit(0)
 
 
-def decision(question):
-    if input("\n%s [Y/n] " % question) in ["", "y", "Y"]:
-        return True
-    return False
-
-
 class Chdir(object):
     """ Context manager for changing the current working directory """
 
diff --git a/cekit/tools.py b/cekit/tools.py
index 6c04985..0dfe05c 100644
--- a/cekit/tools.py
+++ b/cekit/tools.py
@@ -1,6 +1,7 @@
 import logging
 import os
 import shutil
+import sys
 import yaml
 
 from cekit.errors import CekitError
@@ -60,3 +61,16 @@ def load_descriptor(descriptor):
 
     with open(descriptor, 'r') as fh:
         return yaml.safe_load(fh)
+
+
+def decision(question):
+    """Asks user for a question returning True/False answed"""
+    if sys.version_info[0] < 3:
+        if raw_input("\n%s [Y/n] " % question) in ["", "y", "Y"]:
+            return True
+    else:
+        if input("\n%s [Y/n] " % question) in ["", "y", "Y"]:
+            return True
+
+    return False
+
diff --git a/rpm/python-cekit.spec b/rpm/python-cekit.spec
index f239804..4b1c80c 100644
--- a/rpm/python-cekit.spec
+++ b/rpm/python-cekit.spec
@@ -46,7 +46,6 @@ Requires:       python2-setuptools
 
 Requires:       python2-pykwalify
 Requires:       python2-colorlog
-Requires:       python2-future
 Requires:       PyYAML
 Requires:       docker
 Requires:       git
diff --git a/tox.ini b/tox.ini
index f0245ec..60d9535 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,6 @@ passenv=
 deps=
   behave
   docker
-  future
   lxml
   mock
   pytest


Test patch:
diff --git a/tests/test_builder.py b/tests/test_builder.py
index c341b06..2293306 100644
--- a/tests/test_builder.py
+++ b/tests/test_builder.py
@@ -50,7 +50,7 @@ class DistGitMock(object):
 
 def create_osbs_build_object(mocker, builder_type, params):
     mocker.patch.object(subprocess, 'check_output')
-    mocker.patch('cekit.builders.osbs.decision')
+    mocker.patch('cekit.tools.decision')
 
     builder = Builder(builder_type, 'tmp', params)
     builder.dist_git_dir = '/tmp'