Skip to content

Commit

Permalink
return xml str
Browse files Browse the repository at this point in the history
  • Loading branch information
dvklopfenstein committed Nov 20, 2023
1 parent 3f41df5 commit cc00a01
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/pmidcite/eutils/cmds/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,13 @@ def _extract_rsp(self, record, retmode):
traceback.print_exc()
print('\n**FATAL JSONDecodeError:\n{RECORD}'.format(RECORD=record.decode('utf-8')))

if retmode == 'text':
if retmode in {'text', 'asn.1'}:
## print('RECORD:', str(record))
return record.decode('utf-8')

## print('RETMODE', retmode)
## print('RECORD', record)

## print(record)
# <?xml version="1.0" encoding="ISO-8859-1"?>
# <!DOCTYPE ePostResult
# SYSTEM "https://eutils.ncbi.nlm.nih.gov/eutils/dtd/20090526/epost.dtd"
Expand All @@ -366,8 +365,11 @@ def _extract_rsp(self, record, retmode):
# </ePostResult>
# Parse XML
root = ElementTree.fromstring(record)
## print('root.tag', root.tag)
assert root.tag in 'ePostResult', root.tag
print(f'ElementTree.fromstring(record).root:\n{root}')
return root
# TODO
print('root.tag', root.tag)
assert root.tag in 'ePostResult', f'ElementTree.fromstring(record).tag: {root.tag}'
dct = {r.tag.lower():r.text for r in root}
if 'querykey' in dct:
dct['querykey'] = int(dct['querykey'])
Expand Down

0 comments on commit cc00a01

Please sign in to comment.