2929
3030import user_sync .helper
3131import user_sync .identity_type
32- import user_sync .port
3332import user_sync .rules
3433from user_sync import flags
3534from user_sync .error import AssertionException
@@ -282,7 +281,7 @@ def get_umapi_options(self):
282281 secondary_config_sources = {}
283282 primary_config_sources = []
284283 for item in umapi_config :
285- if isinstance (item , six . string_types ):
284+ if isinstance (item , str ):
286285 if secondary_config_sources :
287286 # if we see a string after a dict, the user has done something wrong, and we fail.
288287 raise AssertionException ("Secondary umapi configuration found with no prefix: " + item )
@@ -431,7 +430,7 @@ def get_post_sync_options(self):
431430 def as_list (value ):
432431 if value is None :
433432 return []
434- elif isinstance (value , user_sync . port . list_type ):
433+ elif isinstance (value , list ):
435434 return value
436435 return [value ]
437436
@@ -657,8 +656,8 @@ def create_assertion_error(self, message):
657656 return AssertionException ("%s in: %s" % (message , self .get_full_scope ()))
658657
659658 def describe_types (self , types_to_describe ):
660- if types_to_describe == six . string_types :
661- result = self .describe_types (user_sync . port . string_type )
659+ if types_to_describe == str :
660+ result = self .describe_types (str )
662661 elif isinstance (types_to_describe , tuple ):
663662 result = []
664663 for type_to_describe in types_to_describe :
@@ -765,19 +764,19 @@ def get_string(self, key, none_allowed=False):
765764 """
766765 :rtype: basestring
767766 """
768- return self .get_value (key , six . string_types , none_allowed )
767+ return self .get_value (key , str , none_allowed )
769768
770769 def get_int (self , key , none_allowed = False ):
771770 """
772771 :rtype: int
773772 """
774- return self .get_value (key , user_sync . port . integer_type , none_allowed )
773+ return self .get_value (key , int , none_allowed )
775774
776775 def get_bool (self , key , none_allowed = False ):
777776 """
778777 :rtype: bool
779778 """
780- return self .get_value (key , user_sync . port . boolean_type , none_allowed )
779+ return self .get_value (key , bool , none_allowed )
781780
782781 def get_list (self , key , none_allowed = False ):
783782 """
@@ -881,11 +880,18 @@ def get_value_from_keyring(secure_value_key, user_name):
881880 keyrings .cryptfile .cryptfile .CryptFileKeyring .keyring_key = "none"
882881
883882 import keyring
884- if (isinstance (keyring .get_keyring (), keyring .backends .fail .Keyring ) or
885- isinstance (keyring .get_keyring (), keyring .backends .chainer .ChainerBackend )):
883+ k = keyring .get_keyring ()
884+
885+ # If the keyring cannot connect to a backend, replace it with cryptfile
886+ if isinstance (k , keyring .backends .fail .Keyring ):
886887 keyring .set_keyring (keyrings .cryptfile .cryptfile .CryptFileKeyring ())
887888
888- logging .getLogger ("keyring" ).info ("Using keyring '" + keyring .get_keyring ().name + "' to retrieve: " + secure_value_key )
889+ try :
890+ name = k .backends [0 ].name
891+ except :
892+ name = k .name
893+
894+ logging .getLogger ("keyring" ).info ("Using keyring '{}' to retrieve: {}" .format (name , secure_value_key ))
889895 return keyring .get_password (service_name = secure_value_key , username = user_name )
890896
891897
@@ -1060,7 +1066,7 @@ def process_path_value(cls, val, must_exist, can_have_subdict):
10601066 :param must_exist: whether there must be a value
10611067 :param can_have_subdict: whether the value can be a tagged string
10621068 """
1063- if isinstance (val , six . string_types ):
1069+ if isinstance (val , str ):
10641070 return cls .relative_path (val , must_exist )
10651071 elif isinstance (val , list ):
10661072 vals = []
@@ -1077,7 +1083,7 @@ def relative_path(cls, val, must_exist):
10771083 """
10781084 returns an absolute path that is resolved relative to the file being loaded
10791085 """
1080- if not isinstance (val , six . string_types ):
1086+ if not isinstance (val , str ):
10811087 raise AssertionException ("Expected pathname for setting %s in config file %s" %
10821088 (cls .key_path , cls .filename ))
10831089 if val .startswith ('$(' ) and val .endswith (')' ):
@@ -1107,21 +1113,21 @@ def set_bool_value(self, key, default_value):
11071113 :type key: str
11081114 :type default_value: bool
11091115 """
1110- self .set_value (key , user_sync . port . boolean_type , default_value )
1116+ self .set_value (key , bool , default_value )
11111117
11121118 def set_int_value (self , key , default_value ):
11131119 """
11141120 :type key: str
11151121 :type default_value: int
11161122 """
1117- self .set_value (key , user_sync . port . integer_type , default_value )
1123+ self .set_value (key , int , default_value )
11181124
11191125 def set_string_value (self , key , default_value ):
11201126 """
11211127 :type key: str
11221128 :type default_value: Optional(str)
11231129 """
1124- self .set_value (key , six . string_types , default_value )
1130+ self .set_value (key , str , default_value )
11251131
11261132 def set_dict_value (self , key , default_value ):
11271133 """
@@ -1138,7 +1144,7 @@ def set_value(self, key, allowed_types, default_value):
11381144 self .options [key ] = value
11391145
11401146 def require_string_value (self , key ):
1141- return self .require_value (key , six . string_types )
1147+ return self .require_value (key , str )
11421148
11431149 def require_value (self , key , allowed_types ):
11441150 config = self .default_config
0 commit comments