Skip to content

Commit f3b4d2c

Browse files
committed
code is not executed if contacts is null, but code has been introduced to trigger when contacts==null
1 parent 20ed539 commit f3b4d2c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pycsw/ogc/api/records.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,16 +1285,15 @@ def record2json(record, url, collection, mode='ogcapi-records'):
12851285
})
12861286
except Exception as err:
12871287
LOGGER.exception(f"failed to parse contact of {record.identifier}: {err}")
1288-
for r2 in "creator,publisher,contributor".split(","): # match role-fields with contacts
1289-
if r2 not in roles and hasattr(record, r2) and record[r2] not in [None, '']:
1290-
rcnt.append({
1291-
'organization': record[r2],
1292-
'roles': [r2]
1293-
})
1294-
12951288
except Exception as err:
12961289
LOGGER.warning(f"failed to parse contacts json of {record.identifier}: {err}")
1297-
1290+
for r2 in ["creator","publisher","contributor"]: # match role-fields with contacts
1291+
if r2 not in roles and hasattr(record, r2) and getattr(record, r2) not in [None, '']:
1292+
rcnt.append({
1293+
'organization': getattr(record, r2),
1294+
'roles': [r2]
1295+
})
1296+
if len(rcnt) > 0:
12981297
record_dict['properties']['contacts'] = rcnt
12991298

13001299
if record.themes not in [None, '', 'null']:

0 commit comments

Comments
 (0)