+ "nbsp",
+ exclude=[DCNS("identifier.url"), DCNS("rights.license")]
+ )
+
+def fake_tables(doc):
+ for tabela in doc.findall("//tabela"):
+ # are we dealing with a table of proper structure?
+ # two levels of same tags, and all tags on second level
+ # must be of same count.
+ def tag_count(m, k):
+ m[k.tag] = m.get(k.tag, 0) + 1
+ return m
+
+ child_tags = reduce(tag_count, list(tabela), {})
+ if len(child_tags) != 1:
+ return
+ grandchild_tags = reduce(tag_count, itertools.chain(*[list(c) for c in tabela]), {})
+ if len(grandchild_tags) != 1:
+ return
+ if len(set(grandchild_tags.values())) != 1:
+ return
+
+ for row in tabela:
+ row.tag = 'r'
+ for col in row:
+ col.tag = 'c'
+ return