Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
xbrl_part3_role_ref.py
role_ref_tags = xbrl_dir.xbrl.find_all("link:roleRef")
role_ref_elements = [t.element for t in role_ref_tags]
role_refs = {}
for e in role_ref_elements:
role_refs[e["roleURI"]] = e["xlink:href"]
roles = {}
for r in role_refs:
role_name = taxonomy.read(role_refs[r]).element.find("link:definition").text
roles[role_name] = r
# Show roles
for r in roles:
print(f"{r}\t{roles[r]}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment