diff --git a/musicbrainzngs/mbxml.py b/musicbrainzngs/mbxml.py index e85fe7cb..d57be313 100644 --- a/musicbrainzngs/mbxml.py +++ b/musicbrainzngs/mbxml.py @@ -213,7 +213,7 @@ def parse_area_list(al): def parse_area(area): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "sort-name", "disambiguation"] inner_els = {"life-span": parse_lifespan, "alias-list": parse_alias_list, @@ -233,7 +233,7 @@ def parse_artist_list(al): def parse_artist(artist): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "sort-name", "country", "user-rating", "disambiguation", "gender", "ipi"] inner_els = {"area": parse_area, @@ -266,7 +266,7 @@ def parse_place_list(pl): def parse_place(place): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "address", "ipi", "disambiguation"] inner_els = {"area": parse_area, @@ -288,7 +288,7 @@ def parse_event_list(el): def parse_event(event): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "time", "setlist", "cancelled", "disambiguation", "user-rating"] inner_els = {"life-span": parse_lifespan, "relation-list": parse_relation_list, @@ -304,7 +304,7 @@ def parse_event(event): def parse_instrument(instrument): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "description", "disambiguation"] inner_els = {"relation-list": parse_relation_list, "tag-list": parse_tag_list, @@ -320,7 +320,7 @@ def parse_label_list(ll): def parse_label(label): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "sort-name", "country", "label-code", "user-rating", "ipi", "disambiguation"] inner_els = {"area": parse_area, @@ -473,7 +473,7 @@ def parse_text_representation(textr): def parse_release_group(rg): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["title", "user-rating", "first-release-date", "primary-type", "disambiguation"] inner_els = {"artist-credit": parse_artist_credit, @@ -517,7 +517,7 @@ def parse_series_list(sl): def parse_series(series): result = {} - attribs = ["id", "type", "ext:score"] + attribs = ["id", "type", "type-id", "ext:score"] elements = ["name", "disambiguation"] inner_els = {"alias-list": parse_alias_list, "relation-list": parse_relation_list, @@ -539,7 +539,7 @@ def parse_work_list(wl): def parse_work(work): result = {} - attribs = ["id", "ext:score", "type"] + attribs = ["id", "ext:score", "type", "type-id"] elements = ["title", "user-rating", "language", "iswc", "disambiguation"] inner_els = {"tag-list": parse_tag_list, "user-tag-list": parse_tag_list, @@ -560,12 +560,18 @@ def parse_work_attribute_list(wal): return [parse_work_attribute(wa) for wa in wal] def parse_work_attribute(wa): - attribs = ["type"] + attribs = ["type", "type-id", "value-id"] typeinfo = parse_attributes(attribs, wa) + print(typeinfo) result = {} if typeinfo: result = {"attribute": typeinfo["type"], + "type": typeinfo["type"], "value": wa.text} + if "value-id" in typeinfo: + result["value-id"] = typeinfo["value-id"] + if "type-id" in typeinfo: + result["type-id"] = typeinfo["type-id"] return result @@ -734,7 +740,7 @@ def parse_alias_list(al): def parse_alias(alias): result = {} - attribs = ["locale", "sort-name", "type", "primary", + attribs = ["locale", "sort-name", "type", "type-id", "primary", "begin-date", "end-date"] result.update(parse_attributes(attribs, alias)) diff --git a/test/data/work/3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml b/test/data/work/3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml index f71bcbfc..a47c0580 100644 --- a/test/data/work/3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml +++ b/test/data/work/3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml @@ -1 +1,2 @@ -Symphony No. 2 in E minor, Op. 27: III. AdagioAdagio from Symphony No. 2 in E minor, Op. 27Adagio from Symphony No. 2 in E minor, Op. 27III. Adagio from Symphony No. 2 in E minor, Op. 27Sinfonie Nr. 2 e-moll, Op. 27: III. AdagioSymphonie No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 3 in A minor, Op. 44: II. Adagio ma non troppo교향곡 2번 3악장 "아다지오" [Symphony No. 2 in E minor, Op. 27: III. Adagio] \ No newline at end of file + +Symphony no. 2 in E minor, op. 27: III. AdagiozxxzxxAdagio from Symphony No. 2 in E minor, Op. 27Adagio from Symphony No. 2 in E minor, Op. 27III. Adagio from Symphony No. 2 in E minor, Op. 27Sinfonie Nr. 2 e-moll, Op. 27: III. AdagioSymphonie No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: III. AdagioSymphony No. 2 in E minor, Op. 27: slow movementSymphony No. 3 in A minor, Op. 44: II. Adagio ma non troppo교향곡 2번 3악장 "아다지오" [Symphony No. 2 in E minor, Op. 27: III. Adagio] diff --git a/test/data/work/72c9aad2-3c95-4e3e-8a01-3974f8fef8eb-series-rels.xml b/test/data/work/72c9aad2-3c95-4e3e-8a01-3974f8fef8eb-series-rels.xml index 9b8fb7ef..1a523124 100644 --- a/test/data/work/72c9aad2-3c95-4e3e-8a01-3974f8fef8eb-series-rels.xml +++ b/test/data/work/72c9aad2-3c95-4e3e-8a01-3974f8fef8eb-series-rels.xml @@ -1 +1,2 @@ -Cantata, BuxWV 1 "Accedite gentes, accurite populi"lat0790fa51-15d9-40a2-bca9-9c8eaaa96bef1backwardnumberBuxtehude-Werke-Verzeichnis \ No newline at end of file + +Cantata, BuxWV 1 "Accedite gentes, accurite populi"latlat0790fa51-15d9-40a2-bca9-9c8eaaa96bef1backwardnumberBuxtehude-Werke-Verzeichnis diff --git a/test/data/work/80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml b/test/data/work/80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml index c65a232c..13d16a29 100644 --- a/test/data/work/80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml +++ b/test/data/work/80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml @@ -1,2 +1,2 @@ -Symphony no. 3 in E-flat major, op. 55 "Eroica"zxxE-flat majorSymphonie Nr. 3 Es-Dur, Op. 55 "Eroica"Symphony No. 3, Op. 55 "Eroica" \ No newline at end of file +Symphony no. 3 in E-flat major, op. 55 “Eroica”zxxzxxE-flat majorSinfonia nro 3 Es-duuri, op. 55 ”Eroica”Symphonie Nr. 3 Es-Dur, Op. 55 "Eroica"Symphony No. 3, Op. 55 "Eroica" diff --git a/test/data/work/8e134b32-99b8-4e96-ae5c-426f3be85f4c-attributes.xml b/test/data/work/8e134b32-99b8-4e96-ae5c-426f3be85f4c-attributes.xml index 0985f398..fdfa399d 100644 --- a/test/data/work/8e134b32-99b8-4e96-ae5c-426f3be85f4c-attributes.xml +++ b/test/data/work/8e134b32-99b8-4e96-ae5c-426f3be85f4c-attributes.xml @@ -1 +1 @@ -Hüzzam PeşrevzxxHüzzamPeşrevFahte \ No newline at end of file +Hüzzam PeşrevzxxzxxHüzzamPeşrevFahte \ No newline at end of file diff --git a/test/test_mbxml_work.py b/test/test_mbxml_work.py index f9dc9ecb..62f6cc4d 100644 --- a/test/test_mbxml_work.py +++ b/test/test_mbxml_work.py @@ -13,20 +13,19 @@ def setUp(self): def testWorkAliases(self): res = _common.open_and_parse_test_data(self.datadir, "80737426-8ef3-3a9c-a3a6-9507afb93e93-aliases.xml") aliases = res["work"]["alias-list"] - self.assertEqual(len(aliases), 2) + self.assertEqual(len(aliases), 3) a0 = aliases[0] - self.assertEqual(a0["alias"], 'Symphonie Nr. 3 Es-Dur, Op. 55 "Eroica"') - self.assertEqual(a0["sort-name"], 'Symphonie Nr. 3 Es-Dur, Op. 55 "Eroica"') + self.assertEqual(a0["alias"], u'Sinfonia nro 3 Es-duuri, op. 55 ”Eroica”') + self.assertEqual(a0["sort-name"], u'Sinfonia nro 3 Es-duuri, op. 55 ”Eroica”') - a1 = aliases[1] + a1 = aliases[2] self.assertEqual(a1["alias"], 'Symphony No. 3, Op. 55 "Eroica"') self.assertEqual(a1["sort-name"], 'Symphony No. 3, Op. 55 "Eroica"') - res = _common.open_and_parse_test_data(self.datadir, "3d7c7cd2-da79-37f4-98b8-ccfb1a4ac6c4-aliases.xml") aliases = res["work"]["alias-list"] - self.assertEqual(len(aliases), 10) + self.assertEqual(len(aliases), 11) a0 = aliases[0] self.assertEqual(a0["alias"], "Adagio from Symphony No. 2 in E minor, Op. 27") @@ -38,17 +37,33 @@ def testWorkAttributes(self): self.assertEqual(len(work_attrs), 1) attr = work_attrs[0] - expected = {"attribute": "Key", "value": "E-flat major"} + expected = {"attribute": "Key", + "type": "Key", + "type-id": "7526c19d-3be4-3420-b6cc-9fb6e49fa1a9", + "value": "E-flat major", + "value-id": "7ed963d7-dba9-3357-aefa-f34accb047cd"} self.assertEqual(expected, attr) res = _common.open_and_parse_test_data(self.datadir, "8e134b32-99b8-4e96-ae5c-426f3be85f4c-attributes.xml") work_attrs = res["work"]["attribute-list"] self.assertEqual(len(work_attrs), 3) - expected = {"attribute": "Makam (Ottoman, Turkish)", "value": b"H\xc3\xbczzam".decode("utf-8")} + expected = {"type": "Makam (Ottoman, Turkish)", + "attribute": "Makam (Ottoman, Turkish)", + "value": b"H\xc3\xbczzam".decode("utf-8"), + "type-id": "d7979776-ba34-3e8d-980f-4849b38143d2", + "value-id": "583b64cf-bc36-3dae-8b1d-f834e0a7d9f6"} self.assertEqual(expected, work_attrs[0]) - expected = {"attribute": "Form (Ottoman, Turkish)", "value": b"Pe\xc5\x9frev".decode("utf-8")} + expected = {"type": "Form (Ottoman, Turkish)", + "attribute": "Form (Ottoman, Turkish)", + "value": b"Pe\xc5\x9frev".decode("utf-8"), + "type-id": "77d00f78-0b30-3d91-80de-209a014d33a2", + "value-id": "e2d21124-9c1f-3091-b8cc-b49714a84c8b"} self.assertEqual(expected, work_attrs[1]) - expected = {"attribute": "Usul (Ottoman, Turkish)", "value": "Fahte"} + expected = {"type": "Usul (Ottoman, Turkish)", + "attribute": "Usul (Ottoman, Turkish)", + "value": "Fahte", + "type-id": "29a16dc2-8602-3fee-9a03-a8cc87fa961d", + "value-id": "70636c0a-30da-310c-a7e8-c1113f35dab8"} self.assertEqual(expected, work_attrs[2]) def testWorkRelationAttributes(self): @@ -65,5 +80,5 @@ def testWorkRelationAttributes(self): # New attribute dict format attributes = rels[0]["attributes"] - expected = {"attribute": "number", "value": "BuxWV 1"} + expected = {"attribute": "number", "value": "BuxWV 1", "type-id": "a59c5830-5ec7-38fe-9a21-c7ea54f6650a"} self.assertEqual(expected, attributes[0])