Skip to content

Commit cbae97d

Browse files
authored
remove ISO deprecations (#862)
1 parent a3e8a80 commit cbae97d

4 files changed

Lines changed: 173 additions & 349 deletions

File tree

owslib/iso.py

Lines changed: 27 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212

1313
""" ISO metadata parser """
1414

15-
import warnings
16-
1715
from owslib.etree import etree
1816
from owslib import util
1917
from owslib.namespaces import Namespaces
@@ -35,6 +33,7 @@ class MD_Metadata(object):
3533
def __init__(self, md=None):
3634

3735
if md is None:
36+
self.md = None
3837
self.xml = None
3938
self.identifier = None
4039
self.parentidentifier = None
@@ -50,7 +49,6 @@ def __init__(self, md=None):
5049
self.stdver = None
5150
self.locales = []
5251
self.referencesystem = None
53-
self.identification = None
5452
self.contentinfo = None
5553
self.serviceidentification = None
5654
self.identificationinfo = []
@@ -59,6 +57,7 @@ def __init__(self, md=None):
5957
self.dataquality = None
6058
self.acquisition = None
6159
else:
60+
self.md = md
6261
if hasattr(md, 'getroot'): # standalone document
6362
self.xml = etree.tostring(md.getroot())
6463
else: # part of a larger document
@@ -116,28 +115,8 @@ def __init__(self, md=None):
116115
else:
117116
self.referencesystem = None
118117

119-
# TODO: merge .identificationinfo into .identification
120-
warnings.warn(
121-
'the .identification and .serviceidentification properties will merge into '
122-
'.identification being a list of properties. This is currently implemented '
123-
'in .identificationinfo. '
124-
'Please see https://github.com/geopython/OWSLib/issues/38 for more information',
125-
FutureWarning)
126-
127-
val = md.find(util.nspath_eval('gmd:identificationInfo/gmd:MD_DataIdentification', namespaces))
128-
val2 = md.find(util.nspath_eval('gmd:identificationInfo/srv:SV_ServiceIdentification', namespaces))
129-
130-
if val is not None:
131-
self.identification = MD_DataIdentification(val, 'dataset')
132-
self.serviceidentification = None
133-
elif val2 is not None:
134-
self.identification = MD_DataIdentification(val2, 'service')
135-
self.serviceidentification = SV_ServiceIdentification(val2)
136-
else:
137-
self.identification = None
138-
self.serviceidentification = None
139-
140118
self.identificationinfo = []
119+
141120
for idinfo in md.findall(util.nspath_eval('gmd:identificationInfo', namespaces)):
142121
if len(idinfo) > 0:
143122
val = list(idinfo)[0]
@@ -176,6 +155,22 @@ def __init__(self, md=None):
176155
else:
177156
self.acquisition = None
178157

158+
def get_all_contacts(self):
159+
"""get all contacts in document"""
160+
161+
contacts = []
162+
163+
for ii in self.identificationinfo:
164+
for iic in ii.contact:
165+
contacts.append(iic)
166+
167+
for ct in ['creator', 'publisher', 'contributor']:
168+
iict = getattr(ii, ct)
169+
if iict:
170+
contacts.append(iict)
171+
172+
return list(filter(None, contacts))
173+
179174
def get_default_locale(self):
180175
""" get default gmd:PT_Locale based on gmd:language """
181176

@@ -318,27 +313,18 @@ class MD_Keywords(object):
318313
Class for the metadata MD_Keywords element
319314
"""
320315
def __init__(self, md=None):
321-
warnings.warn(
322-
'The .keywords_object attribute will become .keywords proper in the next release. '
323-
'.keywords_object is a list of ibstances of the Keyword class. '
324-
'See for https://github.com/geopython/OWSLib/pull/765 more details.',
325-
FutureWarning)
326-
327316
if md is None:
328317
self.keywords = []
329-
self.keywords_object = []
330318
self.type = None
331319
self.thesaurus = None
332320
self.kwdtype_codeList = 'http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_KeywordTypeCode'
333321
else:
334322
self.keywords = []
335-
self.keywords_object = []
336323
val = md.findall(util.nspath_eval('gmd:keyword/gco:CharacterString', namespaces))
337324
if len(val) == 0:
338325
val = md.findall(util.nspath_eval('gmd:keyword/gmx:Anchor', namespaces))
339326
for word in val:
340-
self.keywords.append(util.testXMLValue(word))
341-
self.keywords_object.append(Keyword(word))
327+
self.keywords.append(Keyword(word))
342328
self.type = None
343329
val = md.find(util.nspath_eval('gmd:type/gmd:MD_KeywordTypeCode', namespaces))
344330
self.type = util.testXMLAttribute(val, 'codeListValue')
@@ -348,8 +334,8 @@ def __init__(self, md=None):
348334
if val is not None:
349335
self.thesaurus = {}
350336

351-
thesaurus = val.find(util.nspath_eval('gmd:title/gco:CharacterString', namespaces))
352-
self.thesaurus['title'] = util.testXMLValue(thesaurus)
337+
title = val.find(util.nspath_eval('gmd:title/gco:CharacterString', namespaces))
338+
self.thesaurus['title'] = util.testXMLValue(title)
353339
self.thesaurus['url'] = None
354340

355341
if self.thesaurus['title'] is None: # try gmx:Anchor
@@ -358,12 +344,12 @@ def __init__(self, md=None):
358344
self.thesaurus['title'] = util.testXMLValue(t)
359345
self.thesaurus['url'] = t.attrib.get(util.nspath_eval('xlink:href', namespaces))
360346

361-
thesaurus = val.find(util.nspath_eval('gmd:date/gmd:CI_Date/gmd:date/gco:Date', namespaces))
362-
self.thesaurus['date'] = util.testXMLValue(thesaurus)
347+
date_ = val.find(util.nspath_eval('gmd:date/gmd:CI_Date/gmd:date/gco:Date', namespaces))
348+
self.thesaurus['date'] = util.testXMLValue(date_)
363349

364-
thesaurus = val.find(
350+
datetype = val.find(
365351
util.nspath_eval('gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode', namespaces))
366-
self.thesaurus['datetype'] = util.testXMLAttribute(thesaurus, 'codeListValue')
352+
self.thesaurus['datetype'] = util.testXMLAttribute(datetype, 'codeListValue')
367353

368354

369355
class MD_DataIdentification(object):
@@ -401,8 +387,6 @@ def __init__(self, md=None, identtype=None):
401387
self.graphicoverview = []
402388
self.contact = []
403389
self.keywords = []
404-
self.keywords_object = []
405-
self.keywords2 = []
406390
self.topiccategory = []
407391
self.supplementalinformation = None
408392
self.extent = None
@@ -593,50 +577,9 @@ def __init__(self, md=None, identtype=None):
593577
if val:
594578
self.spatialrepresentationtype.append(val)
595579

596-
warnings.warn(
597-
'The .keywords and .keywords2 properties will merge into the '
598-
'.keywords property in the future, with .keywords becoming a list '
599-
'of MD_Keywords instances. This is currently implemented in .keywords2. '
600-
'Please see https://github.com/geopython/OWSLib/issues/301 for more information',
601-
FutureWarning)
602-
603580
self.keywords = []
604-
605-
for i in md.findall(util.nspath_eval('gmd:descriptiveKeywords', namespaces)):
606-
mdkw = {}
607-
mdkw['type'] = _testCodeListValue(i.find(util.nspath_eval(
608-
'gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode', namespaces)))
609-
610-
mdkw['thesaurus'] = {}
611-
612-
val = i.find(util.nspath_eval(
613-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString', namespaces))
614-
mdkw['thesaurus']['title'] = util.testXMLValue(val)
615-
616-
val = i.find(util.nspath_eval(
617-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date',
618-
namespaces))
619-
mdkw['thesaurus']['date'] = util.testXMLValue(val)
620-
621-
val = i.find(util.nspath_eval(
622-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode',
623-
namespaces))
624-
mdkw['thesaurus']['datetype'] = util.testXMLAttribute(val, 'codeListValue')
625-
626-
mdkw['keywords'] = []
627-
628-
for k in i.findall(util.nspath_eval('gmd:MD_Keywords/gmd:keyword', namespaces)):
629-
val = k.find(util.nspath_eval('gco:CharacterString', namespaces))
630-
if val is not None:
631-
val2 = util.testXMLValue(val)
632-
if val2 is not None:
633-
mdkw['keywords'].append(val2)
634-
635-
self.keywords.append(mdkw)
636-
637-
self.keywords2 = []
638581
for mdkw in md.findall(util.nspath_eval('gmd:descriptiveKeywords/gmd:MD_Keywords', namespaces)):
639-
self.keywords2.append(MD_Keywords(mdkw))
582+
self.keywords.append(MD_Keywords(mdkw))
640583

641584
self.topiccategory = []
642585
for i in md.findall(util.nspath_eval('gmd:topicCategory/gmd:MD_TopicCategoryCode', namespaces)):

owslib/iso_che.py

Lines changed: 2 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
""" ISO metadata parser """
1212

13-
import warnings
14-
1513
from owslib.etree import etree
1614
from owslib import util
1715
from owslib.namespaces import Namespaces
@@ -49,7 +47,6 @@ def __init__(self, md=None):
4947
self.stdver = None
5048
self.locales = []
5149
self.referencesystem = None
52-
self.identification = None
5350
self.serviceidentification = None
5451
self.identificationinfo = []
5552
self.distribution = None
@@ -112,28 +109,8 @@ def __init__(self, md=None):
112109
else:
113110
self.referencesystem = None
114111

115-
# TODO: merge .identificationinfo into .identification
116-
warnings.warn(
117-
'the .identification and .serviceidentification properties will merge into '
118-
'.identification being a list of properties. This is currently implemented '
119-
'in .identificationinfo. '
120-
'Please see https://github.com/geopython/OWSLib/issues/38 for more information',
121-
FutureWarning)
122-
123-
val = md.find(util.nspath_eval('gmd:identificationInfo/che:CHE_MD_DataIdentification', namespaces))
124-
val2 = md.find(util.nspath_eval('gmd:identificationInfo/srv:SV_ServiceIdentification', namespaces))
125-
126-
if val is not None:
127-
self.identification = MD_DataIdentification(val, 'dataset')
128-
self.serviceidentification = None
129-
elif val2 is not None:
130-
self.identification = MD_DataIdentification(val2, 'service')
131-
self.serviceidentification = SV_ServiceIdentification(val2)
132-
else:
133-
self.identification = None
134-
self.serviceidentification = None
135-
136112
self.identificationinfo = []
113+
137114
for idinfo in md.findall(util.nspath_eval('gmd:identificationInfo', namespaces)):
138115
if len(idinfo) > 0:
139116
val = list(idinfo)[0]
@@ -368,7 +345,6 @@ def __init__(self, md=None, identtype=None):
368345
self.status = None
369346
self.contact = []
370347
self.keywords = []
371-
self.keywords2 = []
372348
self.topiccategory = []
373349
self.supplementalinformation = None
374350
self.extent = None
@@ -536,50 +512,9 @@ def __init__(self, md=None, identtype=None):
536512
if val:
537513
self.spatialrepresentationtype.append(val)
538514

539-
warnings.warn(
540-
'The .keywords and .keywords2 properties will merge into the '
541-
'.keywords property in the future, with .keywords becoming a list '
542-
'of MD_Keywords instances. This is currently implemented in .keywords2. '
543-
'Please see https://github.com/geopython/OWSLib/issues/301 for more information',
544-
FutureWarning)
545-
546515
self.keywords = []
547-
548-
for i in md.findall(util.nspath_eval('gmd:descriptiveKeywords', namespaces)):
549-
mdkw = {}
550-
mdkw['type'] = _testCodeListValue(i.find(util.nspath_eval(
551-
'gmd:MD_Keywords/gmd:type/gmd:MD_KeywordTypeCode', namespaces)))
552-
553-
mdkw['thesaurus'] = {}
554-
555-
val = i.find(util.nspath_eval(
556-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString', namespaces))
557-
mdkw['thesaurus']['title'] = util.testXMLValue(val)
558-
559-
val = i.find(util.nspath_eval(
560-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:date/gco:Date',
561-
namespaces))
562-
mdkw['thesaurus']['date'] = util.testXMLValue(val)
563-
564-
val = i.find(util.nspath_eval(
565-
'gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:date/gmd:CI_Date/gmd:dateType/gmd:CI_DateTypeCode', # noqa
566-
namespaces))
567-
mdkw['thesaurus']['datetype'] = util.testXMLValue(val)
568-
569-
mdkw['keywords'] = []
570-
571-
for k in i.findall(util.nspath_eval('gmd:MD_Keywords/gmd:keyword', namespaces)):
572-
val = k.find(util.nspath_eval('gco:CharacterString', namespaces))
573-
if val is not None:
574-
val2 = util.testXMLValue(val)
575-
if val2 is not None:
576-
mdkw['keywords'].append(val2)
577-
578-
self.keywords.append(mdkw)
579-
580-
self.keywords2 = []
581516
for mdkw in md.findall(util.nspath_eval('gmd:descriptiveKeywords/gmd:MD_Keywords', namespaces)):
582-
self.keywords2.append(MD_Keywords(mdkw))
517+
self.keywords.append(MD_Keywords(mdkw))
583518

584519
self.topiccategory = []
585520
for i in md.findall(util.nspath_eval('gmd:topicCategory/gmd:MD_TopicCategoryCode', namespaces)):

tests/doctests/iso_keywords.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ Print testing some metadata elements
1212
>>> md.identificationinfo[0].title
1313
'Air temperature'
1414

15-
>>> len(md.identificationinfo[0].keywords2) == len(md.identificationinfo[0].keywords)
15+
>>> len(md.identificationinfo[0].keywords) == len(md.identificationinfo[0].keywords)
1616
True
1717

18-
>>> len(md.identificationinfo[0].keywords2) > 0
18+
>>> len(md.identificationinfo[0].keywords) > 0
1919
True
2020

21-
>>> len(md.identificationinfo[0].keywords2[0].keywords) > 0
21+
>>> len(md.identificationinfo[0].keywords[0].keywords) > 0
2222
True
2323

24-
>>> md.identificationinfo[0].keywords2[0].thesaurus['title']
24+
>>> md.identificationinfo[0].keywords[0].thesaurus['title']
2525
'GEMET - INSPIRE themes, version 1.0'

0 commit comments

Comments
 (0)