Merge lp://qastaging/~antasi/pyexiv2/mutablemapping into lp://qastaging/pyexiv2/0.2.x

Proposed by Antti Siira
Status: Merged
Merged at revision: 327
Proposed branch: lp://qastaging/~antasi/pyexiv2/mutablemapping
Merge into: lp://qastaging/pyexiv2/0.2.x
Diff against target: 88 lines (+55/-1)
2 files modified
src/pyexiv2/metadata.py (+9/-1)
test/metadata.py (+46/-0)
To merge this branch: bzr merge lp://qastaging/~antasi/pyexiv2/mutablemapping
Reviewer Review Type Date Requested Status
Olivier Tilloy code functional Approve
Review via email: mp+36770@code.qastaging.launchpad.net

Description of the change

Make ImageMetadata act like a Python MutableMapping.

To post a comment you must log in.
Revision history for this message
Olivier Tilloy (osomon) wrote :

Thanks for the merge proposal!

I noticed the first revision (326) fixes a separate issue which wasn’t detected by the unit tests. Well spotted! I’m going to tweak this revision a bit and merge it first to keep things atomic, then I’ll review the actual implementation of the MutableMapping interface.

About the bug you fixed:
 - the unit tests didn’t catch this problem, I’ll update them in order to avoid regressions in the future
 - list.remove(x) may raise a ValueError, so the try… except… blocks should be adapted

As for the rest of the review, I’m running out of spare time this week and I’ll be away on holidays next week, but be assured that I’ll review it thoroughly when I get back. Thanks again for the valuable contribution!

326. By Olivier Tilloy

When deleting a tag, remove its key from the cache too.
Many thanks to Antti Siira for spotting the issue and proposing a patch.

Revision history for this message
Olivier Tilloy (osomon) wrote :

I pushed revision 326 to lp:pyexiv2 that fixes the keys not being deleted from the cache when a tag is deleted. Would you mind reverting revision 326 in your branch and push? This will ensure the merge proposal and the diff to review are up-to-date.

Revision history for this message
Olivier Tilloy (osomon) wrote :

A quick go at a functional review while I’m at it:

If I understand correctly the documentation of the collections module (http://docs.python.org/library/collections.html#abcs-abstract-base-classes), a class implementing MutableMapping should implement the following methods:

 - __len__ (from Sized)
 - __iter__ (from Iterable)
 - __contains__ (from Container)
 - __getitem__ (from Mapping)
 - __setitem__
 - __delitem__

Your implementation misses __contains__.

review: Needs Fixing (functional)
Revision history for this message
Antti Siira (antasi) wrote :

> A quick go at a functional review while I’m at it:
> If I understand correctly the documentation of the collections module
> (http://docs.python.org/library/collections.html#abcs-abstract-base-classes),
> ...
> Your implementation misses __contains__.

The __contains__ method comes as a mixin method from Mapping class that MutableMapping inherits, so it is not necessary to implement it.
>>> import pyexiv2
>>> i = pyexiv2.ImageMetadata('/var/tmp/20100703T131613-5fe0998c.jpg')
>>> i.read()
>>> i.__contains__
<bound method ImageMetadata.__contains__ of <pyexiv2.metadata.ImageMetadata object at 0xb7395a6c>>
>>>

It is not stated in the documentation, but I think it uses the implemented __iter__ method to go through the keys and check if the searched item is there.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Right, I overlooked that in the documentation.

327. By Antti Siira

Turn ImageMetadata into MutableMapping

Revision history for this message
Olivier Tilloy (osomon) wrote :

Sorry for the very late review.
It’s all good, thanks a lot for your work.
I merged it into trunk at revision 327.

I will try to update the documentation in a near future to reflect the cool things that implementing the MutableMapping interface offers.

review: Approve (code functional)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches