Skip to content

Instantly share code, notes, and snippets.

@icoxfog417
Created November 20, 2019 09:31
Show Gist options
  • Save icoxfog417/7d910315059011e933f0e7674d66265d to your computer and use it in GitHub Desktop.
Save icoxfog417/7d910315059011e933f0e7674d66265d to your computer and use it in GitHub Desktop.
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