def fix_uri_credentials(uri, to_quoted):
 if (not uri):
  return
 location = glance.store.swift.StoreLocation({})
 if to_quoted:
  location.parse_uri = types.MethodType(legacy_parse_uri, location)
 else:
  location._get_credstring = types.MethodType(legacy__get_credstring, location)
 decrypted_uri = None
 try:
  decrypted_uri = decrypt_location(uri)
 except (TypeError, ValueError) as e:
  raise exception.Invalid(str(e))
 location.parse_uri(decrypted_uri)
 return encrypt_location(location.get_uri())

def fix_uri_credentials ( uri , to_quoted ) : if ( not uri ) : return location = glance . store . swift . StoreLocation ( { } ) if to_quoted : location . parse_uri = types . MethodType ( legacy_parse_uri , location ) else : location . _get_credstring = types . MethodType ( legacy__get_credstring , location ) decrypted_uri = None try : decrypted_uri = decrypt_location ( uri ) except ( TypeError , ValueError ) as e : raise exception . Invalid ( str ( e ) ) location . parse_uri ( decrypted_uri ) return encrypt_location ( location . get_uri ( ) )
fix the given uris embedded credentials by round-tripping with storelocation .