mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Py3: Replace six.string_types with str
In Python 3, six.string_types is just an alias for str. See: https://pagure.io/freeipa/issue/7715 Signed-off-by: Christian Heimes <cheimes@redhat.com> Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
import os
|
||||
import six
|
||||
|
||||
from ipapython.ipautil import run
|
||||
from ipaplatform.paths import paths
|
||||
@@ -51,7 +50,7 @@ def get_real_key(key):
|
||||
One cannot request a key based on the description it was created with
|
||||
so find the one we're looking for.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
result = run([paths.KEYCTL, 'search', KEYRING, KEYTYPE, key],
|
||||
raiseonerr=False, capture_output=True)
|
||||
if result.returncode:
|
||||
@@ -66,7 +65,7 @@ def get_persistent_key(key):
|
||||
|
||||
Assert when key is not a string-type.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
result = run([paths.KEYCTL, 'get_persistent', KEYRING, key],
|
||||
raiseonerr=False, capture_output=True)
|
||||
if result.returncode:
|
||||
@@ -91,7 +90,7 @@ def has_key(key):
|
||||
"""
|
||||
Returns True/False whether the key exists in the keyring.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
try:
|
||||
get_real_key(key)
|
||||
return True
|
||||
@@ -105,7 +104,7 @@ def read_key(key):
|
||||
|
||||
Use pipe instead of print here to ensure we always get the raw data.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
real_key = get_real_key(key)
|
||||
result = run([paths.KEYCTL, 'pipe', real_key], raiseonerr=False,
|
||||
capture_output=True)
|
||||
@@ -119,7 +118,7 @@ def update_key(key, value):
|
||||
"""
|
||||
Update the keyring data. If they key doesn't exist it is created.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
assert isinstance(value, bytes)
|
||||
if has_key(key):
|
||||
real_key = get_real_key(key)
|
||||
@@ -135,7 +134,7 @@ def add_key(key, value):
|
||||
"""
|
||||
Add a key to the kernel keyring.
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
assert isinstance(value, bytes)
|
||||
if has_key(key):
|
||||
raise ValueError('key %s already exists' % key)
|
||||
@@ -149,7 +148,7 @@ def del_key(key):
|
||||
"""
|
||||
Remove a key from the keyring
|
||||
"""
|
||||
assert isinstance(key, six.string_types)
|
||||
assert isinstance(key, str)
|
||||
real_key = get_real_key(key)
|
||||
result = run([paths.KEYCTL, 'unlink', real_key, KEYRING],
|
||||
raiseonerr=False)
|
||||
|
||||
Reference in New Issue
Block a user