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

dq is not in info #1080

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 22 additions & 10 deletions pycsw/core/metadata.py
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make exceptions more explicit?

if hasattr(md, 'dataquality'):
    _set(context, recobj, 'pycsw:Degree', ','.join(md.dataquality.conformancedegree))
    _set(context, recobj, 'pycsw:Lineage', md.dataquality.lineage)
    _set(context, recobj, 'pycsw:SpecificationTitle', md.dataquality.specificationtitle)
    try:
        _set(context, recobj, 'pycsw:SpecificationDate', md.dataquality.specificationDate[0])
    except IndexError:
        LOGGER.debug('No specification date')

Copy link
Contributor Author

@pvgenuchten pvgenuchten Mar 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indexerror is not thrown if element does not exist, not sure when it is thrown
replaced it for normal exception, then logging the exception, was that the idea?

Original file line number Diff line number Diff line change
Expand Up @@ -1521,20 +1521,32 @@ def _parse_iso(context, repos, exml):

_set(context, recobj, 'pycsw:ServiceType', ','.join(service_types))

if hasattr(md_identification, 'dataquality'):
_set(context, recobj, 'pycsw:Degree', md.dataquality.conformancedegree)
_set(context, recobj, 'pycsw:Lineage', md.dataquality.lineage)
_set(context, recobj, 'pycsw:SpecificationTitle', md.dataquality.specificationtitle)
if hasattr(md.dataquality, 'specificationdate'):
_set(context, recobj, 'pycsw:specificationDate',
md.dataquality.specificationdate[0].date)
_set(context, recobj, 'pycsw:SpecificationDateType',
md.dataquality.specificationdate[0].datetype)
if hasattr(md, 'dataquality'):
try:
if hasattr(md.dataquality, 'conformancedegree'):
_set(context, recobj, 'pycsw:Degree', ','.join(md.dataquality.conformancedegree))
except Exception as err:
LOGGER.debug('No dq conformancedegree', err)
try:
if hasattr(md.dataquality, 'lineage'):
_set(context, recobj, 'pycsw:Lineage', md.dataquality.lineage)
except Exception as err:
LOGGER.debug('No dq lineage', err)
try:
if hasattr(md.dataquality, 'specificationtitle'):
_set(context, recobj, 'pycsw:SpecificationTitle', md.dataquality.specificationtitle)
except Exception as err:
LOGGER.debug('No dq specification title', err)
try:
if hasattr(md.dataquality, 'specificationdate'):
_set(context, recobj, 'pycsw:SpecificationDate',
next(iter(md.dataquality.specificationdate), None))
except Exception as err:
LOGGER.debug('No dq specification date', err)

if hasattr(md, 'contact') and len(md.contact) > 0:
_set(context, recobj, 'pycsw:ResponsiblePartyRole', md.contact[0].role)


if hasattr(md, 'contentinfo') and len(md.contentinfo) > 0:
for ci in md.contentinfo:
if isinstance(ci, MD_ImageDescription):
Expand Down