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(): def test_getxmp():
im = Image.open("Tests/images/xmp_test.jpg") with Image.open("Tests/images/xmp_test.jpg") as im:
type_repr = repr(type(im.getxmp())) xmp = im.getxmp()
assert "dict" in type_repr assert isinstance(xmp, dict)
assert isinstance(im.getxmp()["Description"][0]["Version"], str) assert xmp["Description"]["Version"] == "10.4"

View File

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