Escape double quotes in graphviz labels

Signed-off-by: 张梁鹏堃 <zhangliangpengkun@xfusion.com>
This commit is contained in:
张梁鹏堃 2025-04-18 08:12:07 +00:00 committed by Gitee
parent f230dc402c
commit 36879c2d81
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 44 additions and 2 deletions

View File

@ -0,0 +1,38 @@
From 37ca44107dce240f45ccf33e8fb59b5c6702abb9 Mon Sep 17 00:00:00 2001
From: Nathanael Demacon <7271496+quantumsheep@users.noreply.github.com>
Date: Sat, 1 Mar 2025 16:26:24 +0100
Subject: [PATCH] Escape double quotes in graphviz labels (#235)
* escape double quotes in graphviz labels
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
* rename the variable label
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
---------
Signed-off-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
Co-authored-by: Nathanael DEMACON <quantumsheep@users.noreply.github.com>
---
treelib/tree.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/treelib/tree.py b/treelib/tree.py
index 1cc9ac8..7bc4e7e 100644
--- a/treelib/tree.py
+++ b/treelib/tree.py
@@ -1097,7 +1097,8 @@ class Tree(object):
sorting=sorting,
):
nid = self[n].identifier
- state = '"{0}" [label="{1}", shape={2}]'.format(nid, self[n].tag, shape)
+ label = str(self[n].tag).translate(str.maketrans({'"': r"\""}))
+ state = '"{0}" [label="{1}", shape={2}]'.format(nid, label, shape)
nodes.append(state)
for c in self.children(nid):
--
2.33.0

View File

@ -1,11 +1,12 @@
%global _empty_manifest_terminate_build 0
Name: python-treelib
Version: 1.7.0
Release: 1
Release: 2
Summary: A Python 2/3 implementation of tree structure.
License: Apache-2.0
URL: https://github.com/caesar0301/treelib
Source0: https://files.pythonhosted.org/packages/d8/ec/962387a2bd7ece011f47cfa08f06f832fc9fd41b31f4f0007b8b7948eb93/treelib-1.7.0.tar.gz
Patch6000: Escape-double-quotes-in-graphviz-labels.patch
BuildArch: noarch
@ -29,7 +30,7 @@ Provides: python3-treelib-doc
This is a simple tree data structure implementation in python.
%prep
%autosetup -n treelib-%{version}
%autosetup -n treelib-%{version} -p1
%build
%py3_build
@ -69,6 +70,9 @@ mv %{buildroot}/doclist.lst .
%{_docdir}/*
%changelog
* Fri Apr 18 2025 zhangliangpengkun <zhangliangpengkun@xfusion.com> - 1.7.0-2
- DESC:Escape double quotes in graphviz labels
* Tue Nov 05 2024 xiaozai <xiaozai@kylinos.cn> - 1.7.0-1
- Update package to version 1.7.0
- Remove deprecated plugins