Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IndexError: list index out of range #51

Closed
tboenig opened this issue Dec 4, 2020 · 1 comment · Fixed by #56
Closed

IndexError: list index out of range #51

tboenig opened this issue Dec 4, 2020 · 1 comment · Fixed by #56
Labels
bug Something isn't working

Comments

@tboenig
Copy link

tboenig commented Dec 4, 2020

Hi,

I only want to create teiHeader.
The example works:
mm2tei "https://digital.slub-dresden.de/oai/?verb=GetRecord&metadataPrefix=mets&identifier=oai:de:slub-dresden:db:id-453779263"
But my data always gives the following error-message.

(env) mm2tei bsb00000002_mets.xml
Traceback (most recent call last):
  File "mm2tei", line 8, in <module>
    sys.exit(cli())
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/mets_mods2tei/scripts/mets_mods2tei.py", line 35, in cli
    mets.fromfile(f)
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/mets_mods2tei/api/mets.py", line 117, in fromfile       
    self.__spur()
  File "github/mets-mods2tei/env/lib/python3.8/site-packages/mets_mods2tei/api/mets.py", line 148, in __spur
    roles = name.get_role()[0].get_roleTerm()
IndexError: list index out of range

bsb00000002_mets.zip

@kba
Copy link
Collaborator

kba commented Dec 4, 2020

In line 148 of mets_mods2tei/api/mets.py:

            roles = name.get_role()[0].get_roleTerm()

Replace this with

            roles = name.get_role()[0].get_roleTerm() if name.get_role() else []

bertsky added a commit to bertsky/mets-mods2tei that referenced this issue Dec 3, 2021
@bertsky bertsky mentioned this issue Dec 3, 2021
@bertsky bertsky linked a pull request Dec 3, 2021 that will close this issue
@bertsky bertsky added the bug Something isn't working label Dec 13, 2021
@wrznr wrznr closed this as completed in #56 Dec 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants