forked from pool/javapackages-tools
474 lines
17 KiB
Diff
474 lines
17 KiB
Diff
From 06018a8e30d8b781b7b2937fa7c579a5c0758d57 Mon Sep 17 00:00:00 2001
|
|
From: Mikolaj Izdebski <mizdebsk@redhat.com>
|
|
Date: Thu, 23 Jul 2020 10:22:52 +0200
|
|
Subject: [PATCH] Remove dependency on Six compatibility library
|
|
|
|
Python 2 support was dropped, so use of Six is no longer needed.
|
|
---
|
|
Vagrantfile | 1 -
|
|
java-utils/builddep.py | 2 --
|
|
java-utils/mvn_alias.py | 3 ---
|
|
java-utils/mvn_artifact.py | 3 ---
|
|
java-utils/mvn_build.py | 4 +---
|
|
java-utils/mvn_compat_version.py | 2 --
|
|
java-utils/mvn_config.py | 2 --
|
|
java-utils/mvn_file.py | 2 --
|
|
java-utils/mvn_package.py | 2 --
|
|
java-utils/pom_editor.py | 7 +++----
|
|
javapackages-tools.spec | 2 --
|
|
python/javapackages/common/binding.py | 14 ++++++--------
|
|
python/javapackages/common/util.py | 8 --------
|
|
python/javapackages/maven/artifact.py | 5 ++---
|
|
python/javapackages/metadata/artifact.py | 3 +--
|
|
python/javapackages/metadata/dependency.py | 4 +---
|
|
python/javapackages/xmvn/xmvn_config.py | 5 ++---
|
|
requirements.txt | 1 -
|
|
test/maven_depmap_test.py | 5 ++---
|
|
19 files changed, 18 insertions(+), 57 deletions(-)
|
|
|
|
diff --git a/Vagrantfile b/Vagrantfile
|
|
index 64235dc9..095d9065 100644
|
|
--- a/Vagrantfile
|
|
+++ b/Vagrantfile
|
|
@@ -12,7 +12,6 @@ dnf install -y \
|
|
xmlto \
|
|
python{,3} \
|
|
python{,3}-lxml \
|
|
- python{,3}-six \
|
|
python{,3}-nose \
|
|
python{,3}-coverage
|
|
SCRIPT
|
|
diff --git a/java-utils/builddep.py b/java-utils/builddep.py
|
|
index fda36d2d..695e22dc 100644
|
|
--- a/java-utils/builddep.py
|
|
+++ b/java-utils/builddep.py
|
|
@@ -35,7 +35,6 @@
|
|
|
|
from javapackages.maven.artifact import (Artifact, ArtifactFormatException,
|
|
ArtifactValidationException)
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
from lxml import etree
|
|
@@ -53,7 +52,6 @@ def format_epilog(self, formatter):
|
|
if __name__ == "__main__":
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
|
|
(options, args) = parser.parse_args()
|
|
if len(args) != 1:
|
|
diff --git a/java-utils/mvn_alias.py b/java-utils/mvn_alias.py
|
|
index 4979a17a..86d527de 100644
|
|
--- a/java-utils/mvn_alias.py
|
|
+++ b/java-utils/mvn_alias.py
|
|
@@ -36,7 +36,6 @@
|
|
from javapackages.maven.artifact import (Artifact, ArtifactFormatException,
|
|
ArtifactValidationException)
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
|
|
@@ -65,8 +64,6 @@ def format_epilog(self, formatter):
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
-
|
|
(options, args) = parser.parse_args()
|
|
if len(args) < 2:
|
|
parser.error("At least 2 arguments are required")
|
|
diff --git a/java-utils/mvn_artifact.py b/java-utils/mvn_artifact.py
|
|
index d135adf2..11cd6fb2 100644
|
|
--- a/java-utils/mvn_artifact.py
|
|
+++ b/java-utils/mvn_artifact.py
|
|
@@ -42,7 +42,6 @@
|
|
|
|
from javapackages.xmvn.xmvn_resolve import (XMvnResolve, ResolutionRequest,
|
|
XMvnResolveException)
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
import sys
|
|
@@ -240,8 +239,6 @@ def _main():
|
|
parser.add_option("-D", action="append", type="str",
|
|
help="add artifact property", metavar="property=value")
|
|
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
-
|
|
(options, args) = parser.parse_args()
|
|
if len(args) < 1:
|
|
parser.error("At least 1 argument is required")
|
|
diff --git a/java-utils/mvn_build.py b/java-utils/mvn_build.py
|
|
index 720787de..666d791b 100644
|
|
--- a/java-utils/mvn_build.py
|
|
+++ b/java-utils/mvn_build.py
|
|
@@ -41,7 +41,7 @@
|
|
|
|
from javapackages.maven.artifact import Artifact
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig
|
|
-from javapackages.common.util import args_to_unicode, command_exists
|
|
+from javapackages.common.util import command_exists
|
|
from javapackages.common.mock import socket_path as mock_socket
|
|
|
|
|
|
@@ -102,8 +102,6 @@ def goal_callback(option, opt_str, value, parser):
|
|
action="store_true",
|
|
help="Use experimental XMvn javadoc MOJO to generate javadocs.")
|
|
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
-
|
|
(options, args) = parser.parse_args()
|
|
xc = XMvnConfig()
|
|
|
|
diff --git a/java-utils/mvn_compat_version.py b/java-utils/mvn_compat_version.py
|
|
index e4afdbd7..9646bda5 100644
|
|
--- a/java-utils/mvn_compat_version.py
|
|
+++ b/java-utils/mvn_compat_version.py
|
|
@@ -36,7 +36,6 @@
|
|
from javapackages.maven.artifact import (Artifact, ArtifactFormatException,
|
|
ArtifactValidationException)
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
|
|
@@ -64,7 +63,6 @@ def format_epilog(self, formatter):
|
|
if __name__ == "__main__":
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
|
|
(options, args) = parser.parse_args()
|
|
if len(args) < 2:
|
|
diff --git a/java-utils/mvn_config.py b/java-utils/mvn_config.py
|
|
index 7597761e..ee6a788d 100644
|
|
--- a/java-utils/mvn_config.py
|
|
+++ b/java-utils/mvn_config.py
|
|
@@ -34,7 +34,6 @@
|
|
import optparse
|
|
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
|
|
@@ -60,7 +59,6 @@ def format_epilog(self, formatter):
|
|
if __name__ == "__main__":
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
|
|
(options, args) = parser.parse_args()
|
|
if len(args) != 2:
|
|
diff --git a/java-utils/mvn_file.py b/java-utils/mvn_file.py
|
|
index 39d1348f..87eab376 100644
|
|
--- a/java-utils/mvn_file.py
|
|
+++ b/java-utils/mvn_file.py
|
|
@@ -36,7 +36,6 @@
|
|
from javapackages.maven.artifact import (Artifact, ArtifactFormatException,
|
|
ArtifactValidationException)
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig, XMvnConfigException
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
|
|
@@ -64,7 +63,6 @@ def format_epilog(self, formatter):
|
|
if __name__ == "__main__":
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
|
|
(options, args) = parser.parse_args()
|
|
if len(args) < 2:
|
|
diff --git a/java-utils/mvn_package.py b/java-utils/mvn_package.py
|
|
index b74da128..a016e057 100644
|
|
--- a/java-utils/mvn_package.py
|
|
+++ b/java-utils/mvn_package.py
|
|
@@ -36,7 +36,6 @@
|
|
from javapackages.maven.artifact import (Artifact, ArtifactFormatException,
|
|
ArtifactValidationException)
|
|
from javapackages.xmvn.xmvn_config import XMvnConfig
|
|
-from javapackages.common.util import args_to_unicode
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
|
|
|
|
@@ -64,7 +63,6 @@ def format_epilog(self, formatter):
|
|
if __name__ == "__main__":
|
|
parser = SaneParser(usage=usage,
|
|
epilog=epilog)
|
|
- sys.argv = args_to_unicode(sys.argv)
|
|
|
|
(options, args) = parser.parse_args()
|
|
|
|
diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py
|
|
index 82a555b8..adae6e90 100644
|
|
--- a/java-utils/pom_editor.py
|
|
+++ b/java-utils/pom_editor.py
|
|
@@ -5,7 +5,6 @@
|
|
import shutil
|
|
import sys
|
|
import optparse
|
|
-import six
|
|
import io
|
|
|
|
from lxml import etree
|
|
@@ -53,7 +52,7 @@ def from_mvn_str(cls, string):
|
|
return cls(**values)
|
|
|
|
def update(self, artifact):
|
|
- for key, value in six.iteritems(artifact.values):
|
|
+ for key, value in artifact.values.items():
|
|
if key not in parts:
|
|
raise KeyError(key + ' not defined')
|
|
if value:
|
|
@@ -120,7 +119,7 @@ class AttributeArtifact(Artifact):
|
|
@classmethod
|
|
def from_xml(cls, element):
|
|
values = dict([(key, val) for key, val
|
|
- in six.iteritems(element.attrib) if key in parts])
|
|
+ in element.attrib.items() if key in parts])
|
|
return cls(**values)
|
|
|
|
def get_xml(self, node='artifact', extra=''):
|
|
@@ -355,7 +354,7 @@ def make_path(self, node, elements):
|
|
children = node.xpath(elem, namespaces=self.NSMAP)
|
|
if not children:
|
|
name = elements[0]
|
|
- for ns, url in six.iteritems(self.NSMAP):
|
|
+ for ns, url in self.NSMAP.items():
|
|
ns_token = ns + ':'
|
|
url_token = '{' + url + '}'
|
|
name = name.replace(ns_token, url_token)
|
|
diff --git a/javapackages-tools.spec b/javapackages-tools.spec
|
|
index 65f34274..b221f5ca 100644
|
|
--- a/javapackages-tools.spec
|
|
+++ b/javapackages-tools.spec
|
|
@@ -45,7 +45,6 @@ BuildRequires: %{python_prefix}-devel
|
|
BuildRequires: %{python_prefix}-lxml
|
|
BuildRequires: %{python_prefix}-setuptools
|
|
BuildRequires: %{python_prefix}-nose
|
|
-BuildRequires: %{python_prefix}-six
|
|
|
|
Requires: %{?scl_prefix}javapackages-filesystem = %{version}-%{release}
|
|
Requires: coreutils
|
|
@@ -122,7 +121,6 @@ artifact resolution using XMvn resolver.
|
|
%package -n %{?scl_prefix}%{python_prefix}-javapackages
|
|
Summary: Module for handling various files for Java packaging
|
|
Requires: %{python_prefix}-lxml
|
|
-Requires: %{python_prefix}-six
|
|
Obsoletes: %{?scl_prefix}python-javapackages < %{version}-%{release}
|
|
|
|
%description -n %{?scl_prefix}%{python_prefix}-javapackages
|
|
diff --git a/python/javapackages/common/binding.py b/python/javapackages/common/binding.py
|
|
index 550d9f97..f646e229 100644
|
|
--- a/python/javapackages/common/binding.py
|
|
+++ b/python/javapackages/common/binding.py
|
|
@@ -30,8 +30,6 @@
|
|
#
|
|
# Authors: Michael Simacek <msimacek@redhat.com>
|
|
|
|
-import six
|
|
-
|
|
from lxml import etree
|
|
from copy import deepcopy
|
|
|
|
@@ -46,9 +44,9 @@ def _get_item_type(spec):
|
|
spec = tuple(spec)
|
|
ret = spec[0]
|
|
if len(spec) == 1:
|
|
- if isinstance(spec[0], six.string_types):
|
|
+ if isinstance(spec[0], str):
|
|
ret = str
|
|
- elif isinstance(spec[0], six.string_types):
|
|
+ elif isinstance(spec[0], str):
|
|
ret = spec[1]
|
|
assert isinstance(ret, type), ret
|
|
return ret
|
|
@@ -62,12 +60,12 @@ def _get_item_name(spec):
|
|
ret = spec[0].element_name
|
|
elif len(spec) == 2 and isinstance(spec[0], type):
|
|
ret = spec[1]
|
|
- assert isinstance(ret, six.string_types), ret
|
|
+ assert isinstance(ret, str), ret
|
|
return ret
|
|
|
|
|
|
def _is_element(node):
|
|
- return isinstance(node.tag, six.string_types)
|
|
+ return isinstance(node.tag, str)
|
|
|
|
def _localname(element):
|
|
return etree.QName(element.tag).localname
|
|
@@ -86,7 +84,7 @@ def from_element(for_type, element):
|
|
if for_type is dict:
|
|
new = {}
|
|
for child in element:
|
|
- if isinstance(child.tag, six.string_types):
|
|
+ if isinstance(child.tag, str):
|
|
name = _localname(child)
|
|
value = from_element(str, child)
|
|
new[name] = value
|
|
@@ -114,7 +112,7 @@ def _make_element(name, ns=None):
|
|
return etree.Element(name)
|
|
|
|
def to_element(obj, name=None, type_spec=None, ns=None):
|
|
- if isinstance(obj, six.string_types):
|
|
+ if isinstance(obj, str):
|
|
element = _make_element(name, ns=ns)
|
|
element.text = obj
|
|
return element
|
|
diff --git a/python/javapackages/common/util.py b/python/javapackages/common/util.py
|
|
index d9b349a6..4c966687 100644
|
|
--- a/python/javapackages/common/util.py
|
|
+++ b/python/javapackages/common/util.py
|
|
@@ -34,7 +34,6 @@
|
|
import os
|
|
import signal
|
|
import sys
|
|
-import six
|
|
import subprocess
|
|
import logging
|
|
import re
|
|
@@ -60,13 +59,6 @@ def kill_parent_process(rpmconf):
|
|
sys.exit(1)
|
|
|
|
|
|
-def args_to_unicode(args):
|
|
- if six.PY2:
|
|
- for index, arg in enumerate(args):
|
|
- args[index] = arg.decode(sys.getfilesystemencoding())
|
|
- return args
|
|
-
|
|
-
|
|
def execute_command(command, input=None):
|
|
proc = subprocess.Popen([command], shell=True,
|
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
|
diff --git a/python/javapackages/maven/artifact.py b/python/javapackages/maven/artifact.py
|
|
index e79cd014..6ba3ee6f 100644
|
|
--- a/python/javapackages/maven/artifact.py
|
|
+++ b/python/javapackages/maven/artifact.py
|
|
@@ -33,7 +33,6 @@
|
|
# Michal Srb <msrb@redhat.com>
|
|
|
|
import re
|
|
-import six
|
|
|
|
import javapackages.maven.pomreader as POMReader
|
|
import javapackages.common.strutils as Printer
|
|
@@ -190,7 +189,7 @@ def interpolate(self, properties):
|
|
for member in self.__dict__:
|
|
if (not member.startswith('_') and
|
|
getattr(self, member) and
|
|
- isinstance(getattr(self, member), six.string_types)):
|
|
+ isinstance(getattr(self, member), str)):
|
|
curr_value = getattr(self, member)
|
|
prog = re.compile("\$\{([^}]+)\}")
|
|
props = prog.findall(curr_value)
|
|
@@ -205,7 +204,7 @@ def interpolate(self, properties):
|
|
return leftovers
|
|
|
|
def __unicode__(self):
|
|
- return six.text_type(self.get_mvn_str())
|
|
+ return self.get_mvn_str()
|
|
|
|
def __str__(self):
|
|
return self.__unicode__()
|
|
diff --git a/python/javapackages/metadata/artifact.py b/python/javapackages/metadata/artifact.py
|
|
index 3593d76d..72e57e62 100644
|
|
--- a/python/javapackages/metadata/artifact.py
|
|
+++ b/python/javapackages/metadata/artifact.py
|
|
@@ -42,7 +42,6 @@
|
|
|
|
from javapackages.common.binding import ObjectBinding
|
|
|
|
-import six
|
|
import os
|
|
|
|
|
|
@@ -133,7 +132,7 @@ def get_rpm_str(self, namespace=None, pkg_ver=None):
|
|
return "\n".join(result)
|
|
|
|
def __unicode__(self):
|
|
- return six.text_type(self.get_mvn_str())
|
|
+ return self.get_mvn_str()
|
|
|
|
def __str__(self):
|
|
return self.__unicode__()
|
|
diff --git a/python/javapackages/metadata/dependency.py b/python/javapackages/metadata/dependency.py
|
|
index 8f843af4..1e553ac3 100644
|
|
--- a/python/javapackages/metadata/dependency.py
|
|
+++ b/python/javapackages/metadata/dependency.py
|
|
@@ -37,8 +37,6 @@
|
|
|
|
from javapackages.common.binding import ObjectBinding
|
|
|
|
-import six
|
|
-
|
|
|
|
class MetadataDependency(ObjectBinding):
|
|
element_name = 'dependency'
|
|
@@ -100,7 +98,7 @@ def is_skipped(self, skipped_artifacts):
|
|
return False
|
|
|
|
def __unicode__(self):
|
|
- return six.text_type(self.get_mvn_str())
|
|
+ return self.get_mvn_str()
|
|
|
|
def __str__(self):
|
|
return self.__unicode__()
|
|
diff --git a/python/javapackages/xmvn/xmvn_config.py b/python/javapackages/xmvn/xmvn_config.py
|
|
index 66d11344..f2aefbe6 100644
|
|
--- a/python/javapackages/xmvn/xmvn_config.py
|
|
+++ b/python/javapackages/xmvn/xmvn_config.py
|
|
@@ -34,8 +34,7 @@
|
|
import errno
|
|
import os
|
|
import re
|
|
-import six
|
|
-from six import BytesIO
|
|
+from io import BytesIO
|
|
|
|
from javapackages.maven.artifact import ArtifactValidationException
|
|
from javapackages.common.exception import JavaPackagesToolsException
|
|
@@ -131,7 +130,7 @@ def __add_config(self, level1, level2, level3=None, content=None):
|
|
if level3:
|
|
cont_level = SubElement(level2, level3)
|
|
|
|
- if isinstance(content, six.string_types):
|
|
+ if isinstance(content, str):
|
|
cont_level.text = content
|
|
elif isinstance(content, list):
|
|
for elem in content:
|
|
diff --git a/requirements.txt b/requirements.txt
|
|
index db272a8d..ab90481d 100644
|
|
--- a/requirements.txt
|
|
+++ b/requirements.txt
|
|
@@ -1,2 +1 @@
|
|
lxml
|
|
-six
|
|
diff --git a/test/maven_depmap_test.py b/test/maven_depmap_test.py
|
|
index 186ceec1..c21f66d4 100644
|
|
--- a/test/maven_depmap_test.py
|
|
+++ b/test/maven_depmap_test.py
|
|
@@ -1,6 +1,5 @@
|
|
import inspect
|
|
from zipfile import ZipFile
|
|
-import six
|
|
import os
|
|
import unittest
|
|
import shutil
|
|
@@ -68,9 +67,9 @@ def read_archive(self, archive, keep_comments=False):
|
|
mf_file = archive.open(filename)
|
|
try:
|
|
if (keep_comments):
|
|
- res[six.text_type(filename)] = mf_file.readlines()
|
|
+ res[str(filename)] = mf_file.readlines()
|
|
else:
|
|
- res[six.text_type(filename)] = \
|
|
+ res[str(filename)] = \
|
|
[line for line in mf_file.readlines()
|
|
if not line.startswith(b'#')]
|
|
finally:
|