8000 Unable to update node · Issue #19 · dmulyalin/N2G · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Unable to update node #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
devino80228 opened this issue Jan 13, 2023 · 2 comments
Closed

Unable to update node #19

devino80228 opened this issue Jan 13, 2023 · 2 comments

Comments

@devino80228
Copy link
devino80228 commented Jan 13, 2023

Awesome project! I ran into an issue where I was pulling in a diagram off of a drawio file and attempting to update the node. Here is the code I am using:


diagram = drawio_diagram()

diagram.from_file("test.drawio")

diagram.update_node(id="node-1", label="Update Test")

diagram.dump_file(filename="Sample_graph.drawio", folder="./")


But when it gets to updating the node I receive the following error:


AttributeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_xxx\xxx.py in
3 diagram.from_file("test.drawio")
4
----> 5 diagram.update_node(id="node-1", label="Update Test")
6
7 diagram.dump_file(filename="Sample_graph.drawio", folder="./")

~\Anaconda3\lib\site-packages\N2G\plugins\diagrams\N2G_DrawIO.py in update_node(self, id, label, data, url, style, width, height, **kwargs)
247 data = data or {}
248 node_data = {}
--> 249 node = self.current_root.find("./object[@id='{}']".format(id))
250 # update data and url attributes
251 node_data.update(data)

AttributeError: 'NoneType' object has no attribute 'find'


I've confirmed the node ID is accurate and that it is loading in the correct template successfully. I looked at the xml and confirmed the ID there as well, no luck. Any idea what is going on here?

@devino80228
Copy link
Author

I figured it out I think. Two things:

  1. Draw.io uses a newer xml hierarchy where the contains the ID and value/label instead of the older format where preceded . This N2G library is looking for the "object" to identify the node and update the applicable values.

  2. After I corrected for this in my diagrams, I noticed that it would still not update the nodes unless I made sure to turn off compression in File>Properties.

  3. I need to look into elementtree and xml a bit more to correct the code, but it wasn't too difficult for my use case to just update the xml with the object tags.

@dmulyalin
Copy link
Owner

this should be addressed by 3594e00, if you have time, feel free to test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0