mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Support image in conversion from old topologies
This commit is contained in:
5 files changed
+62
-2
No files matched your search
@@ -307,11 +307,31 @@ def _convert_1_3_later(topo, topo_path):
|
||||
"x": int(note["x"]),
|
||||
"y": int(note["y"]),
|
||||
"z": int(note.get("z", 0)),
|
||||
"rotation": int(ellipse.get("rotation", 0)),
|
||||
"rotation": int(note.get("rotation", 0)),
|
||||
"svg": svg
|
||||
}
|
||||
new_topo["topology"]["drawings"].append(new_note)
|
||||
|
||||
# Images
|
||||
for image in topo.get("images", []):
|
||||
img_path = image["path"]
|
||||
# Absolute image path are rewrite to project specific image
|
||||
if os.path.abspath(img_path):
|
||||
try:
|
||||
os.makedirs(os.path.join(topo_dir, "images"), exist_ok=True)
|
||||
shutil.copy(img_path, os.path.join(topo_dir, "images", os.path.basename(img_path)))
|
||||
except OSError:
|
||||
pass
|
||||
new_image = {
|
||||
"drawing_id": str(uuid.uuid4()),
|
||||
"x": int(image["x"]),
|
||||
"y": int(image["y"]),
|
||||
"z": int(image.get("z", 0)),
|
||||
"rotation": int(image.get("rotation", 0)),
|
||||
"svg": os.path.basename(img_path)
|
||||
}
|
||||
new_topo["topology"]["drawings"].append(new_image)
|
||||
|
||||
# Rectangles
|
||||
for rectangle in topo.get("rectangles", []):
|
||||
svg = '<svg height="{height}" width="{width}"><rect fill="{fill}" fill-opacity="1.0" height="{height}" width="{width}" {border_style} /></svg>'.format(
|
||||
@@ -325,7 +345,7 @@ def _convert_1_3_later(topo, topo_path):
|
||||
"x": int(rectangle["x"]),
|
||||
"y": int(rectangle["y"]),
|
||||
"z": int(rectangle.get("z", 0)),
|
||||
"rotation": int(ellipse.get("rotation", 0)),
|
||||
"rotation": int(rectangle.get("rotation", 0)),
|
||||
"svg": svg
|
||||
}
|
||||
new_topo["topology"]["drawings"].append(new_rectangle)
|
||||
|
||||
Reference in new issue
Block a user