Merge pull request #10 from radarhere/feature_xmp

Changed list of single items dictionaries to dictionary
This commit is contained in:
Uriel Martinez 2020-12-30 17:10:48 -06:00 committed by GitHub
commit 0084234aa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 8 deletions

View File

@ -2,8 +2,8 @@ from PIL import Image
def test_getxmp():
im = Image.open("Tests/images/xmp_test.jpg")
type_repr = repr(type(im.getxmp()))
with Image.open("Tests/images/xmp_test.jpg") as im:
xmp = im.getxmp()
assert "dict" in type_repr
assert isinstance(im.getxmp()["Description"][0]["Version"], str)
assert isinstance(xmp, dict)
assert xmp["Description"]["Version"] == "10.4"

View File

@ -1334,10 +1334,10 @@ class Image:
if marker == b"http://ns.adobe.com/xap/1.0/":
root = xml.etree.ElementTree.fromstring(xmp_tags)
for element in root.findall(".//"):
xmp_atribs = []
for child, value in element.attrib.items():
xmp_atribs.append({child.split("}")[1]: value})
self._xmp.update({element.tag.split("}")[1]: xmp_atribs})
self._xmp[element.tag.split("}")[1]] = {
child.split("}")[1]: value
for child, value in element.attrib.items()
}
return self._xmp
def getim(self):