Skip to content

Commit 54d5788

Browse files
committed
fix tests, checking availability of the property on owslib with hasattr()
1 parent 6b52617 commit 54d5788

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

pygeometa/schemas/iso19139/__init__.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,28 +157,24 @@ def import_(self, metadata: str) -> dict:
157157
if identification.temporalextent_end:
158158
temp_extent['end'] = identification.temporalextent_end
159159

160-
161160
mcf['identification']['extents']['temporal'].append(temp_extent)
162161

163-
if m.identification.denominators:
164-
mcf['spatial']['denominators'] = m.identification.denominators
162+
if hasattr(identification, 'denominators'):
163+
mcf['spatial']['denominators'] = identification.denominators
165164

166-
if m.identification.distance:
165+
if hasattr(identification, 'distance'):
167166
mcf['spatial']['resolution'] = []
168-
for k, v in enumerate(m.identification.distance):
167+
for k, v in enumerate(identification.distance):
169168
uom = ''
170-
if m.identification.uom and len(m.identification.uom) > k:
171-
uom = m.identification.uom[k]
169+
if hasattr(identification, 'uom') and len(identification.uom) > k: # noqa
170+
uom = identification.uom[k]
172171
mcf['spatial']['resolution'].append({'distance': v,
173172
'uom': uom})
174173

175-
if m.identification.spatialrepresentationtype and len(m.identification.spatialrepresentationtype) > 0: # noqa
176-
mcf['spatial']['datatype'] = m.identification.spatialrepresentationtype[0] # noqa
177-
178-
if m.identification.accessconstraints:
179-
mcf['identification']['accessconstraints'] = m.identification.accessconstraints[0] # noqa
174+
if hasattr(identification, 'spatialrepresentationtype') and len(identification.spatialrepresentationtype) > 0: # noqa
175+
mcf['spatial']['datatype'] = identification.spatialrepresentationtype[0] # noqa
180176

181-
if identification.accessconstraints:
177+
if hasattr(identification, 'accessconstraints'):
182178
mcf['identification']['accessconstraints'] = identification.accessconstraints[0] # noqa
183179

184180
mcf['identification']['status'] = identification.status

0 commit comments

Comments
 (0)