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

Add Python methods to hashtable so it can be used like a dict #5620

Merged
merged 3 commits into from Aug 16, 2018

Conversation

Projects
None yet
3 participants
@geographika
Member

geographika commented Jun 20, 2018

Supersedes #5614

Add various Python methods so that a hashtable can be used like a dict. See #5582 for background.
API is now as follows:

import mapscript
ht = mapscript.hashTableObj()

ht["key1"] = "value1"
ht["key2"] = "value2"
ht["key3"] = "value3"
ht["key4"] = "value4"

del ht["key1"]
print(ht.keys)
print(len(ht))
print("k1" in ht)
print(len(ht))

Or for a more concrete example:

print(map.web.metadata.keys()) # ['wms_srs', 'ows_enable_request', 'ows_http_max_age']
print(map.web.metadata["wms_srs"]) # EPSG:4326
map.web.metadata["wms_srs"] = "EPSG:2157"
print(map.web.metadata["wms_srs"])  # EPSG:2157
@geographika

This comment has been minimized.

Member

geographika commented Jun 26, 2018

Is this likely to make the 7.2 cut? If not I can recreate the pull request against master.

The functionality is tested by both mapscript/python/tests/cases/hashtest.py and msautotest/mspython/test_mapio.py

Currently the hashtable implementation in Python Mapscript doesn't match the docs, or allow setting of values.

@sdlime

This comment has been minimized.

Member

sdlime commented Jun 26, 2018

@geographika

This comment has been minimized.

Member

geographika commented Jun 26, 2018

@sdlime - I don't have commit rights so can't help there sorry!

@rouault wrote the original SWIG typemap so could have reservations, although the new approach has the same API as the test_mapio.py that was written to test they typemap so should be ok.

@sdlime

This comment has been minimized.

Member

sdlime commented Jun 26, 2018

Probably should wait on a blessing from @rouault before pulling the trigger then.

@rouault rouault merged commit c59ab11 into mapserver:branch-7-2 Aug 16, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@rouault

This comment has been minimized.

Contributor

rouault commented Aug 16, 2018

@geographika @sdlime Sorry, I missed your previous pings. Too many notifications from too many repositories.. Squashed and merged

@geographika

This comment has been minimized.

Member

geographika commented Aug 17, 2018

@rouault - thanks for merging!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment