def _write_credentials_file(credentials_file, credentials):
 data = {'file_version': 2, 'credentials': {}}
 for (key, credential) in iteritems(credentials):
  credential_json = credential.to_json()
  encoded_credential = _helpers._from_bytes(base64.b64encode(_helpers._to_bytes(credential_json)))
  data['credentials'][key] = encoded_credential
 credentials_file.seek(0)
 json.dump(data, credentials_file)
 credentials_file.truncate()

def _write_credentials_file ( credentials_file , credentials ) : data = { 'file_version' : 2 , 'credentials' : { } } for ( key , credential ) in iteritems ( credentials ) : credential_json = credential . to_json ( ) encoded_credential = _helpers . _from_bytes ( base64 . b64encode ( _helpers . _to_bytes ( credential_json ) ) ) data [ 'credentials' ] [ key ] = encoded_credential credentials_file . seek ( 0 ) json . dump ( data , credentials_file ) credentials_file . truncate ( )
writes credentials to a file .