Skip to content
Open
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
3 changes: 1 addition & 2 deletions kmip/core/config_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@

import logging
import os

from six.moves.configparser import ConfigParser
from configparser import ConfigParser

FILE_PATH = os.path.dirname(os.path.abspath(__file__))

Expand Down
6 changes: 2 additions & 4 deletions kmip/core/messages/payloads/discover_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from six.moves import xrange

from kmip.core import enums
from kmip.core.messages.contents import ProtocolVersion
from kmip.core.messages.payloads import base
Expand Down Expand Up @@ -66,7 +64,7 @@ def validate(self):

def __validate(self):
if isinstance(self.protocol_versions, list):
for i in xrange(len(self.protocol_versions)):
for i in range(len(self.protocol_versions)):
protocol_version = self.protocol_versions[i]
if not isinstance(protocol_version, ProtocolVersion):
msg = "invalid protocol version ({0} in list)".format(i)
Expand Down Expand Up @@ -125,7 +123,7 @@ def validate(self):

def __validate(self):
if isinstance(self.protocol_versions, list):
for i in xrange(len(self.protocol_versions)):
for i in range(len(self.protocol_versions)):
protocol_version = self.protocol_versions[i]
if not isinstance(protocol_version, ProtocolVersion):
msg = "invalid protocol version ({0} in list)".format(i)
Expand Down
9 changes: 4 additions & 5 deletions kmip/core/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import abc
import six
from six.moves import xrange
import struct

from kmip.core import attributes
Expand Down Expand Up @@ -946,7 +945,7 @@ def __eq__(self, other):

# TODO (ph) Allow order independence?

for i in six.moves.range(len(self.attributes)):
for i in range(len(self.attributes)):
a = self.attributes[i]
b = other.attributes[i]

Expand Down Expand Up @@ -2363,7 +2362,7 @@ def __validate(self):
raise TypeError(msg)

if isinstance(self.attributes, list):
for i in xrange(len(self.attributes)):
for i in range(len(self.attributes)):
attribute = self.attributes[i]
if not isinstance(attribute, Attribute):
msg = "invalid attribute ({0} in list)".format(i)
Expand Down Expand Up @@ -3514,14 +3513,14 @@ def __eq__(self, other):

# TODO (peter-hamilton) Allow order independence?

for i in xrange(len(self.names)):
for i in range(len(self.names)):
a = self.names[i]
b = other.names[i]

if a != b:
return False

for i in xrange(len(self.attributes)):
for i in range(len(self.attributes)):
a = self.attributes[i]
b = other.attributes[i]

Expand Down
9 changes: 4 additions & 5 deletions kmip/core/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
# under the License.

import json
import six

from kmip.core import enums


def parse_policy(policy):
result = {}

for object_type, operation_policies in six.iteritems(policy):
for object_type, operation_policies in policy.items():
processed_operation_policies = {}

for operation, permission in six.iteritems(operation_policies):
for operation, permission in operation_policies.items():
try:
enum_operation = enums.Operation[operation]
except Exception:
Expand Down Expand Up @@ -80,7 +79,7 @@ def read_policy_from_file(path):
continue

# Use subset checking to determine what type of policy we have
sections = set([s for s in six.iterkeys(object_policy)])
sections = set([s for s in object_policy.keys()])
if sections <= policy_sections:
parsed_policies = dict()

Expand All @@ -91,7 +90,7 @@ def read_policy_from_file(path):
group_policies = object_policy.get('groups')
if group_policies:
parsed_group_policies = dict()
for group_name, group_policy in six.iteritems(group_policies):
for group_name, group_policy in group_policies.items():
parsed_group_policies[group_name] = parse_policy(
group_policy
)
Expand Down
10 changes: 4 additions & 6 deletions kmip/demos/units/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import logging
import sys

from six.moves import xrange

from kmip.core import enums

from kmip.demos import utils
Expand Down Expand Up @@ -69,26 +67,26 @@

logger.info('number of operations supported: {0}'.format(
len(operations)))
for i in xrange(len(operations)):
for i in range(len(operations)):
logger.info('operation supported: {0}'.format(operations[i]))

logger.info('number of object types supported: {0}'.format(
len(object_types)))
for i in xrange(len(object_types)):
for i in range(len(object_types)):
logger.info('object type supported: {0}'.format(object_types[i]))

logger.info('vendor identification: {0}'.format(vendor_identification))
logger.info('server information: {0}'.format(server_information))

logger.info('number of application namespaces supported: {0}'.format(
len(application_namespaces)))
for i in xrange(len(application_namespaces)):
for i in range(len(application_namespaces)):
logger.info('application namespace supported: {0}'.format(
application_namespaces[i]))

logger.info('number of extensions supported: {0}'.format(
len(extension_information)))
for i in xrange(len(extension_information)):
for i in range(len(extension_information)):
logger.info('extension supported: {0}'.format(
extension_information[i]))

Expand Down
4 changes: 1 addition & 3 deletions kmip/services/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@
# under the License.

import abc
import six
import ssl


@six.add_metaclass(abc.ABCMeta)
class AuthenticationSuite(object):
class AuthenticationSuite(metaclass=abc.ABCMeta):
"""
An authentication suite used to establish secure network connections.

Expand Down
4 changes: 1 addition & 3 deletions kmip/services/server/auth/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,9 @@
# under the License.

import abc
import six


@six.add_metaclass(abc.ABCMeta)
class AuthAPI:
class AuthAPI(metaclass=abc.ABCMeta):
"""
The base class for an authentication API connector.
"""
Expand Down
3 changes: 1 addition & 2 deletions kmip/services/server/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.

import configparser
import logging
import os

from six.moves import configparser

from kmip.core import exceptions


Expand Down
5 changes: 1 addition & 4 deletions kmip/services/server/crypto/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
from abc import ABCMeta
from abc import abstractmethod

import six


@six.add_metaclass(ABCMeta)
class CryptographicEngine(object):
class CryptographicEngine(metaclass=ABCMeta):
"""
The abstract base class of the cryptographic engine hierarchy.

Expand Down
5 changes: 2 additions & 3 deletions kmip/services/server/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import copy
import logging
import six
import sqlalchemy

from sqlalchemy.orm import exc
Expand Down Expand Up @@ -847,7 +846,7 @@ def _set_attributes_on_managed_object(self, managed_object, attributes):
Given a kmip.pie object and a dictionary of attributes, attempt to set
the attribute values on the object.
"""
for attribute_name, attribute_value in six.iteritems(attributes):
for attribute_name, attribute_value in attributes.items():
object_type = managed_object._object_type
if self._attribute_policy.is_attribute_applicable_to_object_type(
attribute_name,
Expand Down Expand Up @@ -1446,7 +1445,7 @@ def _process_create_key_pair(self, payload):

# Propagate common attributes if not overridden by the public/private
# attribute sets
for key, value in six.iteritems(common_attributes):
for key, value in common_attributes.items():
if key not in public_key_attributes.keys():
public_key_attributes.update([(key, value)])
if key not in private_key_attributes.keys():
Expand Down
3 changes: 1 addition & 2 deletions kmip/services/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import optparse
import os
import signal
import six
import socket
import ssl
import sys
Expand Down Expand Up @@ -243,7 +242,7 @@ def start(self):
self.manager = multiprocessing.Manager()
self.policies = self.manager.dict()
policies = copy.deepcopy(operation_policy.policies)
for policy_name, policy_set in six.iteritems(policies):
for policy_name, policy_set in policies.items():
self.policies[policy_name] = policy_set

self.policy_monitor = monitor.PolicyDirectoryMonitor(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from six.moves import xrange

from testtools import TestCase

from kmip.core import utils
Expand Down Expand Up @@ -82,7 +80,7 @@ def _test_read(self, stream, payload, protocol_versions):
expected, observed)
self.assertEqual(expected, observed, msg)

for i in xrange(len(protocol_versions)):
for i in range(len(protocol_versions)):
expected = protocol_versions[i]
observed = payload.protocol_versions[i]

Expand Down Expand Up @@ -209,7 +207,7 @@ def _test_read(self, stream, payload, protocol_versions):
expected, observed)
self.assertEqual(expected, observed, msg)

for i in xrange(len(protocol_versions)):
for i in range(len(protocol_versions)):
expected = protocol_versions[i]
observed = payload.protocol_versions[i]

Expand Down
7 changes: 2 additions & 5 deletions kmip/tests/unit/core/misc/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from six import binary_type
from six import string_types

from testtools import TestCase

from kmip.core.enums import KeyFormatType as KeyFormatTypeEnum
Expand Down Expand Up @@ -43,7 +40,7 @@ def tearDown(self):
super(TestCertificateValue, self).tearDown()

def _test_init(self, value):
if (isinstance(value, binary_type)) or (value is None):
if (isinstance(value, bytes)) or (value is None):
certificate_value = CertificateValue(value)

if value is None:
Expand Down Expand Up @@ -131,7 +128,7 @@ def tearDown(self):
super(TestVendorIdentification, self).tearDown()

def _test_init(self, value):
if (isinstance(value, string_types)) or (value is None):
if (isinstance(value, str)) or (value is None):
vendor_identification = VendorIdentification(value)

if value is None:
Expand Down
3 changes: 1 addition & 2 deletions kmip/tests/unit/core/misc/test_server_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from six import string_types
from testtools import TestCase

from kmip.core.misc import ServerInformation
Expand Down Expand Up @@ -231,7 +230,7 @@ def _test_str(self, data):

# TODO (peter-hamilton) This should be binary_type. Fix involves
# TODO (peter-hamilton) refining BytearrayStream implementation.
expected = string_types
expected = str
observed = str_repr

msg = "expected {0}, observed {1}".format(expected, observed)
Expand Down
3 changes: 1 addition & 2 deletions kmip/tests/unit/core/objects/test_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# License for the specific language governing permissions and limitations
# under the License.

from six import string_types
import testtools
from testtools import TestCase

Expand Down Expand Up @@ -1511,7 +1510,7 @@ def tearDown(self):
super(TestExtensionName, self).tearDown()

def _test_init(self, value):
if (isinstance(value, string_types)) or (value is None):
if (isinstance(value, str)) or (value is None):
extension_name = ExtensionName(value)

if value is None:
Expand Down
14 changes: 6 additions & 8 deletions kmip/tests/unit/services/server/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.

import configparser
import logging
import mock

import six
from six.moves import configparser

import testtools

from kmip.core import exceptions
Expand Down Expand Up @@ -135,7 +133,7 @@ def test_load_settings(self):
with mock.patch('os.path.exists') as os_mock:
os_mock.return_value = True
with mock.patch(
'six.moves.configparser.ConfigParser.read'
'configparser.ConfigParser.read'
) as parser_mock:
c.load_settings("/test/path/server.conf")
c._logger.info.assert_any_call(
Expand Down Expand Up @@ -189,14 +187,14 @@ def test_parse_auth_settings(self):
self.assertIsInstance(c[1], dict)

if c[0] == 'auth:slugs':
self.assertIn('enabled', six.iterkeys(c[1]))
self.assertIn('enabled', c[1].keys())
self.assertEqual('True', c[1]['enabled'])
self.assertIn('url', six.iterkeys(c[1]))
self.assertIn('url', c[1].keys())
self.assertEqual('http://127.0.0.1:8080/slugs/', c[1]['url'])
elif c[0] == 'auth:ldap':
self.assertIn('enabled', six.iterkeys(c[1]))
self.assertIn('enabled', c[1].keys())
self.assertEqual('False', c[1]['enabled'])
self.assertIn('url', six.iterkeys(c[1]))
self.assertIn('url', c[1].keys())
self.assertEqual('http://127.0.0.1:8080/ldap/', c[1]['url'])

def test_parse_auth_settings_no_config(self):
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
cryptography>=2.5
enum-compat
requests
six>=1.11.0
sqlalchemy>=1.0
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
},
install_requires=[
"cryptography",
"enum-compat",
"requests",
"six",
"sqlalchemy"
Expand Down
Loading