ckan / ckanext-spatial

Geospatial extension for CKAN
http://docs.ckan.org/projects/ckanext-spatial
125 stars 190 forks source link

ckan_pycsw.py cannot run on Python 3.2 or greater #299

Open frafra opened 1 year ago

frafra commented 1 year ago
  File "/usr/lib/ckan/venv/src/ckanext/ckanext-spatial/bin/ckan_pycsw.py", line 27, in setup_db
    table_name = pycsw_config.get("repository", "table", "records")
TypeError: get() takes 3 positional arguments but 4 were given

Changed in version 3.2: Arguments raw, vars and fallback are keyword only to protect users from trying to use the third argument as the fallback fallback (especially when using the mapping protocol). -- https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.get

etj commented 1 year ago

It could be fixed using

    table_name = pycsw_config.get("repository", "table", fallback="records")

but you also need to import configparser, also to prevent the warning about the deprecation of the old parser:

DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2.

If you need to use env vars in the config file you also need to import EnvInterpolation from the related pycsw package and init the config in this way:

config = configparser.ConfigParser(interpolation=EnvInterpolation())