From 5379fb5e28c1ae5bbee86084d9d816a11d3fd41e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= Date: Mon, 28 Aug 2017 14:31:09 +0200 Subject: [PATCH] Check for correct string class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use python-six and check against correct string class on both Python 2 and Python 3. Signed-off-by: Lubomír Sedlář --- pungi.spec | 2 ++ pungi/checks.py | 3 ++- pungi/createiso.py | 3 ++- pungi/wrappers/scm.py | 5 +++-- setup.py | 1 + 5 files changed, 10 insertions(+), 4 deletions(-) diff --git a/pungi.spec b/pungi.spec index e8f2cd75..9a85a38a 100644 --- a/pungi.spec +++ b/pungi.spec @@ -18,6 +18,7 @@ BuildRequires: python-enum34 BuildRequires: python2-dnf BuildRequires: python2-multilib BuildRequires: python2-libcomps +BuildRequires: python2-six Requires: createrepo >= 0.4.11 Requires: yum => 3.4.3-28 @@ -46,6 +47,7 @@ Requires: python-enum34 Requires: python2-dnf Requires: python2-multilib Requires: python2-libcomps +Requires: python2-six BuildArch: noarch diff --git a/pungi/checks.py b/pungi/checks.py index 9563f171..4eccd882 100644 --- a/pungi/checks.py +++ b/pungi/checks.py @@ -40,8 +40,9 @@ from __future__ import print_function import contextlib import os.path import platform -import jsonschema import re +import jsonschema +import six from kobo.shortcuts import force_list from productmd.composeinfo import COMPOSE_TYPES diff --git a/pungi/createiso.py b/pungi/createiso.py index 8014a505..16815544 100644 --- a/pungi/createiso.py +++ b/pungi/createiso.py @@ -4,6 +4,7 @@ from __future__ import print_function import os import pipes +import six from collections import namedtuple from .wrappers import iso @@ -27,7 +28,7 @@ def quote(str): def emit(f, cmd): """Print line of shell code into the stream.""" - if isinstance(cmd, basestring): + if isinstance(cmd, six.string_types): print(cmd, file=f) else: print(' '.join([quote(x) for x in cmd]), file=f) diff --git a/pungi/wrappers/scm.py b/pungi/wrappers/scm.py index 6ae225a5..2232ce0d 100644 --- a/pungi/wrappers/scm.py +++ b/pungi/wrappers/scm.py @@ -19,6 +19,7 @@ import os import shutil import pipes import glob +import six import kobo.log from kobo.shortcuts import run, force_list @@ -226,7 +227,7 @@ def get_file_from_scm(scm_dict, target_path, logger=None): >>> get_file_from_scm(scm_dict, target_path) ['/tmp/path/share/variants.dtd'] """ - if isinstance(scm_dict, basestring): + if isinstance(scm_dict, six.string_types): scm_type = "file" scm_repo = None scm_file = os.path.abspath(scm_dict) @@ -279,7 +280,7 @@ def get_dir_from_scm(scm_dict, target_path, logger=None): >>> get_dir_from_scm(scm_dict, target_path) ['/tmp/path/share/variants.dtd', '/tmp/path/share/rawhide-fedora.ks', ...] """ - if isinstance(scm_dict, basestring): + if isinstance(scm_dict, six.string_types): scm_type = "file" scm_repo = None scm_dir = os.path.abspath(scm_dict) diff --git a/setup.py b/setup.py index 921f3e0d..a0c6b5b9 100755 --- a/setup.py +++ b/setup.py @@ -61,6 +61,7 @@ setup( "lockfile", "lxml", "productmd", + "six", ], tests_require = [ "mock",