Skip to content
This repository has been archived by the owner on May 8, 2020. It is now read-only.

Commit

Permalink
Minor checks in get_wallet_records.
Browse files Browse the repository at this point in the history
Signed-off-by: fabienpe <fabienpe@users.noreply.github.com>
  • Loading branch information
fabienpe committed May 27, 2019
1 parent 8c0be47 commit 5549cf5
Showing 1 changed file with 21 additions and 17 deletions.
38 changes: 21 additions & 17 deletions python/indy_sdk_utils.py
Expand Up @@ -75,22 +75,26 @@ async def get_wallet_records(wallet_handle: int, search_type: str,
:return: List of all records found.
"""
list_of_records = []
search_handle = await non_secrets.open_wallet_search(wallet_handle,
search_type,
query_json,
json.dumps({'retrieveTotalCount': True}))
while True:
results_json = await non_secrets.fetch_wallet_search_next_records(wallet_handle,
search_handle, 10)
results = json.loads(results_json)

if results['totalCount'] == 0 or results['records'] is None:
break
for record in results['records']:
record_value = json.loads(record['value'])
record_value['_id'] = record['id']
list_of_records.append(record_value)

await non_secrets.close_wallet_search(search_handle)
if search_type:
search_handle = \
await non_secrets.open_wallet_search(wallet_handle, search_type, query_json,
json.dumps({'retrieveTotalCount': True}))
while True:
results_json = await non_secrets.fetch_wallet_search_next_records(wallet_handle,
search_handle, 10)
results = json.loads(results_json)

if results['totalCount'] == 0 or results['records'] is None:
break
for record in results['records']:
try:
record_value = json.loads(record['value'])
if isinstance(record_value, dict):
record_value['_id'] = record['id']
except json.decoder.JSONDecodeError:
record_value = record['value']
list_of_records.append(record_value)

await non_secrets.close_wallet_search(search_handle)

return list_of_records

0 comments on commit 5549cf5

Please sign in to comment.