Last active
November 20, 2019 09:39
-
-
Save icoxfog417/94195c02f8d4a9f9811a61b7d0806dd2 to your computer and use it in GitHub Desktop.
xbrl_part3_read_link.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pre_def = xbrl_dir.pre.find( | |
"link:presentationLink", {"xlink:role": roles["貸借対照表"]}) | |
nodes = {} | |
for i, arc in enumerate(pre_def.find_all("link:presentationArc")): | |
if not arc["xlink:arcrole"].endswith("parent-child"): | |
print("Unexpected arctype.") | |
continue | |
parent = Node(document.find("link:loc", {"xlink:label": arc["xlink:from"]}), i) | |
child = Node(document.find("link:loc", {"xlink:label": arc["xlink:to"]}), arc["order"]) | |
if child.name not in nodes: | |
nodes[child.name] = child | |
else: | |
nodes[child.name].order = arc["order"] | |
if parent.name not in nodes: | |
nodes[parent.name] = parent | |
nodes[child.name].add_parent(nodes[parent.name]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment