From 4da4b7535658c80a6e14f6a32aaa10a531581394 Mon Sep 17 00:00:00 2001 From: "J.-S. Caux" <J.S.Caux@uva.nl> Date: Sun, 2 May 2021 15:48:43 +0200 Subject: [PATCH] Tweak caller check methods --- scipost/services.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/scipost/services.py b/scipost/services.py index a0388e017..796c5d505 100644 --- a/scipost/services.py +++ b/scipost/services.py @@ -228,8 +228,10 @@ class FigshareCaller: } def _result_present(self, data): - if 'id' in data and data['id'] == int(self.identifier): - return True + try: + return data['id'] == int(self.identifier) + except KeyError: + pass return False @@ -272,7 +274,6 @@ class OSFPreprintsCaller: def _format_data(self): """Format data to prefill SubmissionForm as much as possible""" - print(self._osfpreprints_data) title = self._osfpreprints_data['attributes']['title'] contributors_data = self._osfpreprints_data['embeds']['contributors']['data'] author_list = [d['embeds']['users']['data']['attributes']['full_name'] for d in contributors_data] @@ -293,8 +294,8 @@ class OSFPreprintsCaller: } def _result_present(self, response_content): - if ('data' in response_content and - 'id' in response_content['data'] and - response_content['data']['id'] == self.identifier): - return True + try: + return response_content['data']['id'] == self.identifier + except KeyError: + pass return False -- GitLab