Skip to content

Commit e655b0a

Browse files
committed
ITemref processed after the current node, not before.
1 parent b0d55ac commit e655b0a

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

extruct/w3cmicrodata.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,18 @@ def _extract_item(self, node, items_seen, base_url):
7979
item["id"] = itemid.strip()
8080

8181
properties = collections.defaultdict(list)
82-
# start with item references
82+
for name, value in self._extract_properties(
83+
node, items_seen=items_seen, base_url=base_url):
84+
properties[name].append(value)
85+
86+
# process item references
8387
refs = node.get('itemref', '').split()
8488
if refs:
8589
for refid in refs:
8690
for name, value in self._extract_property_refs(
8791
node, refid, items_seen=items_seen, base_url=base_url):
8892
properties[name].append(value)
8993

90-
for name, value in self._extract_properties(
91-
node, items_seen=items_seen, base_url=base_url):
92-
properties[name].append(value)
93-
9494
props = []
9595
for (name, values) in properties.items():
9696
if not self.strict and len(values) == 1:

tests/samples/schema.org/product-ref.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
},
1212
"prop3": "REFERENCED TO INCLUDE PROPERTIES AND ALSO INDIVIDUAL PRODUCT",
1313
"image": [
14-
"img-2.jpg",
15-
"anvil_executive.jpg"
14+
"anvil_executive.jpg",
15+
"img-2.jpg"
1616
],
1717
"related_products": [
1818
{

tests/samples/w3c/microdata.5.3.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
{"properties": {"a": ["1", "2"], "b": ["test"]}},
33
{"properties": {"a": ["1", "2"], "b": ["test"]}},
44
{"properties": {"a": ["1", "2"], "b": ["test"]}},
5-
{"properties": {"a": ["1", "2"], "b": ["test"]}}
5+
{"properties": {"a": ["2", "1"], "b": ["test"]}}
66
]
77

tests/test_microdata.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,5 +183,4 @@ def test_join_none(self):
183183

184184
mde = MicrodataExtractor()
185185
data = mde.extract(body)
186-
print(json.dumps(data, indent=4))
187186
self.assertEqual(data, expected)

0 commit comments

Comments
 (0)