Skip to content

NoneType object has no attribute attrib #973

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

Closed
pvgenuchten opened this issue Feb 25, 2025 · 3 comments
Closed

NoneType object has no attribute attrib #973

pvgenuchten opened this issue Feb 25, 2025 · 3 comments

Comments

@pvgenuchten
Copy link
Contributor

when querying the csw endpoint of inspire on datasets of atmospheric conditions, i get this error

  File "/lib/python3.10/site-packages/owslib/iso.py", line 195, in __init__
    util.nspath_eval('gmd:characterEncoding/gmd:MD_CharacterSetCode', namespaces)).attrib.get(
AttributeError: 'NoneType' object has no attribute 'attrib'

not sure which record caused the error

@geographika
Copy link
Contributor

@pvgenuchten - are you able to provide the query that raised this error?

url = 'https://inspire-geoportal.ec.europa.eu/srv/eng/csw'
c = cs(url)
c.getrecords2()
print(c.results)
# {'matches': 346714, 'returned': 10, 'nextrecord': 11}
# query with a filter?
# uuid_filter = fes.PropertyIsEqualTo(propertyname='sys.siteuuid', literal="{%s}" % "1706F520-2647-4A33-B7BF-592FAFDE4B45")
# c.getrecords2([uuid_filter], esn='full', maxrecords=2)

@pvgenuchten
Copy link
Contributor Author

pvgenuchten commented Feb 28, 2025

code is this one:

from owslib.csw import CatalogueServiceWeb
from owslib.fes import PropertyIsEqualTo
url = 'https://inspire-geoportal.ec.europa.eu/srv/eng/csw'
csw = CatalogueServiceWeb(url)
cq = PropertyIsEqualTo('th_httpinspireeceuropaeutheme-theme.link', 'http://inspire.ec.europa.eu/theme/ac')
csw.getrecords2(constraints=[cq], outputschema='http://www.isotc211.org/2005/gmd', maxrecords=50, startposition=150,  esn='full')    

indeed, code snippet is required to reproduce

pvgenuchten added a commit to pvgenuchten/OWSLib that referenced this issue Mar 1, 2025
add a null check before using attrib
tomkralidis pushed a commit that referenced this issue Mar 8, 2025
* resolves issue #973

add a null check before using attrib

* Add pytest_httpserver and unit test

* Remove live server URL

* Mark online

---------

Co-authored-by: sethg <sethg@geographika.co.uk>
@geographika
Copy link
Contributor

Closed with #978

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants