Skip to content

Commit 0102f2c

Browse files
Merge pull request #761 from adobe-apiplatform/Remove_six_dependency
remove six pkg references
2 parents ae60e59 + 3d32976 commit 0102f2c

File tree

14 files changed

+84
-85
lines changed

14 files changed

+84
-85
lines changed

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
'pycryptodome==3.9.7',
5252
'ldap3',
5353
'PyYAML',
54-
'six',
5554
'umapi-client==2.19',
5655
'click',
5756
'click-default-group',

user_sync/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -355,12 +355,12 @@ def begin_work_umapi(config_loader: UMAPIConfigLoader):
355355
# make sure that all the adobe groups are from known umapi connector names
356356
primary_umapi_config, secondary_umapi_configs = config_loader.get_target_options()
357357
referenced_umapi_names = set()
358-
for groups in six.itervalues(directory_groups):
358+
for groups in directory_groups.values():
359359
for group in groups:
360360
umapi_name = group.umapi_name
361361
if umapi_name != PRIMARY_TARGET_NAME:
362362
referenced_umapi_names.add(umapi_name)
363-
referenced_umapi_names.difference_update(six.iterkeys(secondary_umapi_configs))
363+
referenced_umapi_names.difference_update(secondary_umapi_configs.keys())
364364
if len(referenced_umapi_names) > 0:
365365
raise AssertionException('Adobe groups reference unknown umapi connectors: %s' % referenced_umapi_names)
366366

@@ -380,7 +380,7 @@ def begin_work_umapi(config_loader: UMAPIConfigLoader):
380380
primary_name = '.primary' if secondary_umapi_configs else ''
381381
umapi_primary_connector = UmapiConnector(primary_name, primary_umapi_config, True)
382382
umapi_other_connectors = {}
383-
for secondary_umapi_name, secondary_config in six.iteritems(secondary_umapi_configs):
383+
for secondary_umapi_name, secondary_config in secondary_umapi_configs.items():
384384
umapi_secondary_conector = UmapiConnector(".secondary.%s" % secondary_umapi_name,
385385
secondary_config)
386386
umapi_other_connectors[secondary_umapi_name] = umapi_secondary_conector
@@ -646,7 +646,7 @@ def log_parameters(argv, config_loader):
646646
logger.info('------- Command line arguments -------')
647647
logger.info(' '.join(argv))
648648
logger.debug('-------- Resulting invocation options --------')
649-
for parameter_name, parameter_value in six.iteritems(config_loader.get_invocation_options()):
649+
for parameter_name, parameter_value in config_loader.get_invocation_options().items():
650650
logger.debug(' %s: %s', parameter_name, parameter_value)
651651
logger.info('-------------------------------------')
652652

user_sync/certgen.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ def create_key():
5656
def create_cert(subject_fields, key):
5757
try:
5858
subject = issuer = x509.Name([
59-
x509.NameAttribute(NameOID.COUNTRY_NAME, six.text_type(subject_fields['countryName'])),
59+
x509.NameAttribute(NameOID.COUNTRY_NAME, str(subject_fields['countryName'])),
6060
x509.NameAttribute(NameOID.STATE_OR_PROVINCE_NAME,
61-
six.text_type(subject_fields['stateOrProvinceName'])),
62-
x509.NameAttribute(NameOID.LOCALITY_NAME, six.text_type(subject_fields['localityName'])),
63-
x509.NameAttribute(NameOID.ORGANIZATION_NAME, six.text_type(subject_fields['organizationName'])),
64-
x509.NameAttribute(NameOID.COMMON_NAME, six.text_type(subject_fields['commonName'])),
65-
x509.NameAttribute(NameOID.EMAIL_ADDRESS, six.text_type(subject_fields['emailAddress']))
61+
str(subject_fields['stateOrProvinceName'])),
62+
x509.NameAttribute(NameOID.LOCALITY_NAME, str(subject_fields['localityName'])),
63+
x509.NameAttribute(NameOID.ORGANIZATION_NAME, str(subject_fields['organizationName'])),
64+
x509.NameAttribute(NameOID.COMMON_NAME, str(subject_fields['commonName'])),
65+
x509.NameAttribute(NameOID.EMAIL_ADDRESS, str(subject_fields['emailAddress']))
6666
])
6767

6868
return x509.CertificateBuilder().subject_name(

user_sync/config/common.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import os
33

44
import re
5-
import six
5+
# import six
66
import yaml
77
from abc import ABC, abstractmethod
88

@@ -72,7 +72,7 @@ def iter_configs(self):
7272
:rtype iterable(ObjectConfig)
7373
"""
7474
yield self
75-
for child_config in six.itervalues(self.child_configs):
75+
for child_config in self.child_configs.values():
7676
for subtree_config in child_config.iter_configs():
7777
yield subtree_config
7878

@@ -88,7 +88,7 @@ def create_assertion_error(self, message):
8888
return AssertionException("%s in: %s" % (message, self.get_full_scope()))
8989

9090
def describe_types(self, types_to_describe):
91-
if types_to_describe == six.string_types:
91+
if types_to_describe == str:
9292
result = self.describe_types(str)
9393
elif isinstance(types_to_describe, tuple):
9494
result = []
@@ -166,7 +166,7 @@ def __contains__(self, item):
166166
return item in self.value
167167

168168
def iter_keys(self):
169-
return six.iterkeys(self.value)
169+
return self.value.keys()
170170

171171
def iter_unused_keys(self):
172172
for key in self.iter_keys():
@@ -196,7 +196,7 @@ def get_string(self, key, none_allowed=False) -> str:
196196
"""
197197
:rtype: basestring
198198
"""
199-
return self.get_value(key, six.string_types, none_allowed)
199+
return self.get_value(key, str, none_allowed)
200200

201201
def get_int(self, key, none_allowed=False):
202202
"""
@@ -393,7 +393,7 @@ def load_from_yaml(self, filepath, path_keys):
393393
if not isinstance(yml, dict):
394394
# malformed YML files produce a non-dictionary
395395
raise AssertionException("Configuration file or command '{}' does not contain settings".format(filepath))
396-
for path_key, options in six.iteritems(path_keys):
396+
for path_key, options in path_keys.items():
397397
key_path = path_key
398398
keys = path_key.split('/')
399399
self.process_path_key(dirpath, filename, key_path, yml, keys, 1, *options)
@@ -419,7 +419,7 @@ def process_path_key(self, dirpath, filename, key_path, dictionary, keys, level,
419419
# if a wildcard is specified at this level, that means we
420420
# should process all keys as path values
421421
if key == "*":
422-
for key, val in six.iteritems(dictionary):
422+
for key, val in dictionary.items():
423423
dictionary[key] = self.process_path_value(dirpath, filename, key_path, val, must_exist, can_have_subdict)
424424
elif key in dictionary:
425425
dictionary[key] = self.process_path_value(dirpath, filename, key_path, dictionary[key], must_exist, can_have_subdict)
@@ -451,13 +451,13 @@ def process_path_value(self, dirpath, filename, key_path, val, must_exist, can_h
451451
:param must_exist: whether there must be a value
452452
:param can_have_subdict: whether the value can be a tagged string
453453
"""
454-
if isinstance(val, six.string_types):
454+
if isinstance(val, str):
455455
return self.relative_path(dirpath, filename, key_path, val, must_exist)
456456
elif isinstance(val, list):
457457
vals = []
458458
for entry in val:
459459
if can_have_subdict and isinstance(entry, dict):
460-
for subkey, subval in six.iteritems(entry):
460+
for subkey, subval in entry.items():
461461
vals.append({subkey: self.relative_path(dirpath, filename, key_path, subval, must_exist)})
462462
else:
463463
vals.append(self.relative_path(dirpath, filename, key_path, entry, must_exist))
@@ -468,7 +468,7 @@ def relative_path(dirpath, filename, key_path, val, must_exist):
468468
"""
469469
returns an absolute path that is resolved relative to the file being loaded
470470
"""
471-
if not isinstance(val, six.string_types):
471+
if not isinstance(val, str):
472472
raise AssertionException("Expected pathname for setting {} in config file {}".format(key_path, filename))
473473
if val.startswith('$(') and val.endswith(')'):
474474
raise AssertionException("Shell execution is no longer supported: {}".format(val))
@@ -509,7 +509,7 @@ def set_string_value(self, key, default_value):
509509
:type key: str
510510
:type default_value: Optional(str)
511511
"""
512-
self.set_value(key, six.string_types, default_value)
512+
self.set_value(key, str, default_value)
513513

514514
def set_dict_value(self, key, default_value):
515515
"""
@@ -526,7 +526,7 @@ def set_value(self, key, allowed_types, default_value):
526526
self.options[key] = value
527527

528528
def require_string_value(self, key):
529-
return self.require_value(key, six.string_types)
529+
return self.require_value(key, str)
530530

531531
def require_value(self, key, allowed_types):
532532
config = self.default_config
@@ -539,7 +539,7 @@ def require_value(self, key, allowed_types):
539539
def resolve_invocation_options(options: dict, invocation_config: DictConfig, invocation_defaults: dict, args: dict) -> dict:
540540
# get overrides from the main config
541541
if invocation_config:
542-
for k, v in six.iteritems(invocation_defaults):
542+
for k, v in invocation_defaults.items():
543543
if isinstance(v, bool):
544544
val = invocation_config.get_bool(k, True)
545545
if val is not None:

user_sync/config/sign_sync.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def get_engine_options(self) -> dict:
233233
sign_only_user_action = user_sync.get_value('sign_only_user_action', (str, int))
234234
options['user_sync']['sign_only_user_action'] = sign_only_user_action
235235
if options.get('directory_group_mapped'):
236-
options['directory_group_filter'] = set(six.iterkeys(self.directory_groups))
236+
options['directory_group_filter'] = set(self.directory_groups.keys())
237237
options['cache'] = self.main_config.get_dict('cache')
238238
return options
239239

user_sync/config/user_sync.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ def get_target_options(self):
283283
raise AssertionException("Secondary umapi configuration found with no prefix: " + item)
284284
primary_config_sources.append(item)
285285
elif isinstance(item, dict):
286-
for key, val in six.iteritems(item):
286+
for key, val in item.items():
287287
secondary_config_sources[key] = as_list(val)
288288
primary_config = self.create_umapi_options(primary_config_sources)
289289
secondary_configs = {key: self.create_umapi_options(val)
290-
for key, val in six.iteritems(secondary_config_sources)}
290+
for key, val in secondary_config_sources.items()}
291291
return primary_config, secondary_configs
292292

293293
def get_directory_connector_module_name(self):
@@ -431,7 +431,7 @@ def combine_dicts(dicts):
431431
result = {}
432432
for dict_item in dicts:
433433
if isinstance(dict_item, dict):
434-
for dict_key, dict_val in six.iteritems(dict_item):
434+
for dict_key, dict_val in dict_item.items():
435435
result_val = result.get(dict_key)
436436
if isinstance(result_val, dict) and isinstance(dict_val, dict):
437437
result_val.update(dict_val)
@@ -545,7 +545,7 @@ def get_engine_options(self):
545545
# set the directory group filter from the mapping, if requested.
546546
# This must come late, after any prior adds to the mapping from other parameters.
547547
if options.get('directory_group_mapped'):
548-
options['directory_group_filter'] = set(six.iterkeys(self.directory_groups))
548+
options['directory_group_filter'] = set(self.directory_groups.keys())
549549

550550
# set the adobe group filter from the mapping, if requested.
551551
if options.get('adobe_group_mapped') is True:

user_sync/connector/connector_umapi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def __len__(self):
283283

284284
def convert_user_attributes_to_params(self, attributes):
285285
params = {}
286-
for key, value in six.iteritems(attributes):
286+
for key, value in attributes.items():
287287
if key == 'firstname':
288288
key = 'first_name'
289289
elif key == 'lastname':

user_sync/connector/directory_adobe_console.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ def load_users_and_groups(self, groups, extended_attributes, all_users):
143143
self.logger.debug('Count of users in any groups: %d', len(grouped_user_records))
144144
self.logger.debug('Count of users not in any groups: %d',
145145
len(self.user_by_usr_key) - len(grouped_user_records))
146-
return six.itervalues(self.user_by_usr_key)
146+
return self.user_by_usr_key.values()
147147
else:
148-
return six.itervalues(grouped_user_records)
148+
return grouped_user_records.values()
149149

150150
def convert_user(self, record):
151151

user_sync/connector/directory_csv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def load_users_and_groups(self, groups, extended_attributes, all_users):
7171
self.logger.debug('Reading from: %s', file_path)
7272
self.users = users = self.read_users(file_path, extended_attributes)
7373
self.logger.debug('Number of users loaded: %d', len(users))
74-
return six.itervalues(users)
74+
return users.values()
7575

7676
def read_users(self, file_path, extended_attributes):
7777
"""

0 commit comments

Comments
 (0)