Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dependency on six #391

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conu/apidefs/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from conu.utils.http_client import HttpClient, get_url

import requests
from six.moves.urllib.parse import urlunsplit
from urllib.parse import urlunsplit
from contextlib import contextmanager


Expand Down
4 changes: 1 addition & 3 deletions conu/backend/buildah/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import os
import subprocess

import six

from conu.apidefs.backend import get_backend_tmpdir
from conu.apidefs.image import Image
from conu.apidefs.metadata import ImageMetadata
Expand Down Expand Up @@ -75,7 +73,7 @@ def __init__(self, repository, tag="latest", identifier=None,
:param pull_policy: enum, strategy to apply for pulling the image
"""
super(BuildahImage, self).__init__(repository, tag=tag)
if not isinstance(tag, (six.string_types, None.__class__)):
if not isinstance(tag, (str, None.__class__)):
raise ConuException("'tag' is not a string type")
if not isinstance(pull_policy, BuildahImagePullPolicy):
raise ConuException("'pull_policy' is not an instance of BuildahImagePullPolicy")
Expand Down
4 changes: 1 addition & 3 deletions conu/backend/docker/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import enum
from tempfile import mkdtemp

import six

from kubernetes.client.rest import ApiException

from conu.apidefs.metadata import ImageMetadata
Expand Down Expand Up @@ -110,7 +108,7 @@ def __init__(self, repository, tag="latest", identifier=None,
:param pull_policy: enum, strategy to apply for pulling the image
"""
super(DockerImage, self).__init__(repository, tag=tag)
if not isinstance(tag, (six.string_types, None.__class__)):
if not isinstance(tag, (str, None.__class__)):
raise ConuException("'tag' is not a string type")
if not isinstance(pull_policy, DockerImagePullPolicy):
raise ConuException("'pull_policy' is not an instance of DockerImagePullPolicy")
Expand Down
4 changes: 1 addition & 3 deletions conu/backend/podman/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
import os
import subprocess

import six

from conu.apidefs.backend import get_backend_tmpdir
from conu.apidefs.image import Image
from conu.apidefs.metadata import ImageMetadata
Expand Down Expand Up @@ -61,7 +59,7 @@ def __init__(self, repository, tag="latest", identifier=None,
:param pull_policy: enum, strategy to apply for pulling the image
"""
super(PodmanImage, self).__init__(repository, tag=tag)
if not isinstance(tag, (six.string_types, None.__class__)):
if not isinstance(tag, (str, None.__class__)):
raise ConuException("'tag' is not a string type")
if not isinstance(pull_policy, PodmanImagePullPolicy):
raise ConuException("'pull_policy' is not an instance of PodmanImagePullPolicy")
Expand Down
9 changes: 3 additions & 6 deletions conu/utils/filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@
from conu.exceptions import ConuException
from conu.utils import run_cmd, is_selinux_disabled, setfacl_command_exists, chcon_command_exists

import six


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -85,14 +82,14 @@ def __init__(self, path, mode=None, user_owner=None, group_owner=None, facl_rule
self.facl_rules = facl_rules

# os.chown wants int
if isinstance(user_owner, six.string_types):
if isinstance(user_owner, str):
try:
self.owner = pwd.getpwnam(user_owner)[2]
except KeyError as ex:
raise ConuException("User %r not found, error message: %r" % (user_owner, ex))
else:
self.owner = user_owner
if isinstance(group_owner, six.string_types):
if isinstance(group_owner, str):
try:
self.group = pwd.getpwnam(group_owner)[3]
except KeyError as ex:
Expand Down Expand Up @@ -246,7 +243,7 @@ def create_from_tuple(cls, volume):
:param volume: tuple in one one of the following forms: target | source,target | source,target,mode
:return: instance of Volume
"""
if isinstance(volume, six.string_types):
if isinstance(volume, str):
return Volume(target=volume)
elif len(volume) == 2:
return Volume(source=volume[0],
Expand Down
2 changes: 1 addition & 1 deletion conu/utils/http_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT
#
from requests import Session
from six.moves.urllib.parse import urlunsplit
from urllib.parse import urlunsplit


def get_url(path, host, port, method="http"):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
requests
six
docker
kubernetes==8.0.0
pytest
5 changes: 2 additions & 3 deletions tests/integration/test_buildah.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import subprocess

import pytest
from six import string_types

from conu import ConuException, random_str
from conu.fixtures import buildah_backend
Expand Down Expand Up @@ -31,7 +30,7 @@ def test_buildah_image(buildah_backend):
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "BuildahImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
assert isinstance(image.get_id(), str)
new_image = image.tag_image(tag="test")
assert new_image.is_present()
new_image.rmi(via_name=True)
Expand All @@ -55,7 +54,7 @@ def test_buildah_container(buildah_backend):
assert "Config" in c.inspect()
assert c.get_id() == str(c)
assert repr(c)
assert isinstance(c.get_id(), string_types)
assert isinstance(c.get_id(), str)
finally:
c.delete(force=True)

Expand Down
7 changes: 3 additions & 4 deletions tests/integration/test_docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
Directory

from conu.backend.docker.skopeo import SkopeoTransport
from six import string_types


@pytest.mark.parametrize("reference,result", [
Expand Down Expand Up @@ -129,7 +128,7 @@ def test_image():
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "DockerImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
assert isinstance(image.get_id(), str)
new_image = image.tag_image(tag="test")
new_image.rmi(via_name=True)

Expand All @@ -155,7 +154,7 @@ def test_container():
assert "Config" in c.inspect()
assert c.get_id() == str(c)
assert repr(c)
assert isinstance(c.get_id(), string_types)
assert isinstance(c.get_id(), str)
finally:
c.delete(force=True)

Expand Down Expand Up @@ -618,6 +617,6 @@ def test_run_via_api():
assert "Config" in c.inspect()
assert c.get_id() == str(c)
assert repr(c)
assert isinstance(c.get_id(), string_types)
assert isinstance(c.get_id(), str)
finally:
c.delete(force=True)
17 changes: 4 additions & 13 deletions tests/integration/test_filesystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import os

import pytest
import six

from conu.backend.docker.backend import DockerBackend
from conu.backend.docker.container import ConuException
Expand Down Expand Up @@ -53,12 +52,8 @@ def test_container_copy_from(docker_container, tmpdir):
assert fd.read() == FEDORA_RELEASE

tmpdir.mkdir("etc")
if six.PY2:
with pytest.raises(OSError):
fs.copy_from("/etc", str(tmpdir))
else:
with pytest.raises(FileExistsError):
fs.copy_from("/etc", str(tmpdir))
with pytest.raises(FileExistsError):
fs.copy_from("/etc", str(tmpdir))


def test_container_get_file(docker_container):
Expand Down Expand Up @@ -119,12 +114,8 @@ def test_image_copy_from(docker_image, tmpdir):
assert fd.read() == FEDORA_RELEASE

tmpdir.mkdir("etc")
if six.PY2:
with pytest.raises(OSError):
fs.copy_from("/etc", str(tmpdir))
else:
with pytest.raises(FileExistsError):
fs.copy_from("/etc", str(tmpdir))
with pytest.raises(FileExistsError):
fs.copy_from("/etc", str(tmpdir))


def test_image_get_file(docker_image):
Expand Down
6 changes: 2 additions & 4 deletions tests/integration/test_podman.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
from conu.exceptions import ConuException
from conu import Directory

from six import string_types

import pytest


Expand Down Expand Up @@ -55,7 +53,7 @@ def test_podman_image(podman_backend):
assert "registry.fedoraproject.org/fedora-minimal:33" == str(image)
assert "PodmanImage(repository=%s, tag=%s)" % (FEDORA_MINIMAL_REPOSITORY,
FEDORA_MINIMAL_REPOSITORY_TAG) == repr(image)
assert isinstance(image.get_id(), string_types)
assert isinstance(image.get_id(), str)
new_image = image.tag_image(tag="test")
assert new_image.is_present()
new_image.rmi(via_name=True)
Expand All @@ -82,7 +80,7 @@ def test_container(podman_backend, podman_run_builder):
assert "Config" in c.inspect()
assert c.get_id() == str(c)
assert repr(c)
assert isinstance(c.get_id(), string_types)
assert isinstance(c.get_id(), str)
finally:
c.delete(force=True)

Expand Down