check if profile exists
@@ -3,8 +3,22 @@ from openreview import *
super_user_id = 'OpenReview.net'
+def get_profile(client, value):
+ profile = None
+ try:
+ profile = client.get_profile(value)
+ except openreview.OpenReviewException as e:
+ # throw an error if it is something other than "not found"
+ if e[0][0] != 'Profile not found':
+ print "OpenReviewException: {0}".format(e)
+ return e
+ return profile
+
def create_profile(client, email, first, last, middle = None):
+ profile = get_profile(client, email)
+
+ if not profile:
response = client.get_tildeusername(first, last, middle)
tilde_id = response['username']
@@ -32,5 +46,7 @@ def create_profile(client, email, first, last, middle = None):
else:
raise OpenReviewException('There is already a profile with this first, middle and last name')
+ else:
+ raise OpenReviewException('There is already a profile with this email: ' + email)
