From 1ce1a6459724bf469b9e98ff961ce56bb0d513c0 Mon Sep 17 00:00:00 2001 From: BalooRM Date: Sat, 18 Apr 2020 16:44:26 -0400 Subject: [PATCH] Testing for searchtype == 'fastidentity' in the function get() and passing the operation value enables PubChemPy to execute a fast identity search with POST. The original response = request() statement was put into the else clause of the if statement. --- pubchempy.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pubchempy.py b/pubchempy.py index 8de112f..f393508 100644 --- a/pubchempy.py +++ b/pubchempy.py @@ -277,7 +277,11 @@ def request(identifier, namespace='cid', domain='compound', operation=None, outp def get(identifier, namespace='cid', domain='compound', operation=None, output='JSON', searchtype=None, **kwargs): """Request wrapper that automatically handles async requests.""" if (searchtype and searchtype != 'xref') or namespace in ['formula']: - response = request(identifier, namespace, domain, None, 'JSON', searchtype, **kwargs).read() + # BalooRM - if searchtype == 'fastidentity', pass operation in place of None + if searchtype == 'fastidentity': + response = request(identifier, namespace, domain, operation, 'JSON', searchtype, **kwargs).read() + else: + response = request(identifier, namespace, domain, None, 'JSON', searchtype, **kwargs).read() status = json.loads(response.decode()) if 'Waiting' in status and 'ListKey' in status['Waiting']: identifier = status['Waiting']['ListKey']