summaryrefslogtreecommitdiffstats
path: root/vstf/vstf/common/candy_text.py
diff options
context:
space:
mode:
authorYiting.Li <liyiting@huawei.com>2016-01-19 14:39:31 +0800
committerJun Li <matthew.lijun@huawei.com>2016-01-20 01:23:27 +0000
commit6d9521fff519412e66d585d8f980824414a218eb (patch)
tree6b6403f87c494ce2592228560f4078c8d3763ba5 /vstf/vstf/common/candy_text.py
parent9bd22008562f748f82a3053f53a969027876a852 (diff)
JIRA: BOTTLENECKS-29
add the performance test framework add the copyright on the code. Change-Id: I6ec9eefe65bf07c2dd6c636d1b90b64da303952e Signed-off-by: Yiting.Li <liyiting@huawei.com> (cherry picked from commit 5b4f794932cb9b28ec679e6dd88e6febb2a5db7b)
Diffstat (limited to 'vstf/vstf/common/candy_text.py')
-rwxr-xr-xvstf/vstf/common/candy_text.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/vstf/vstf/common/candy_text.py b/vstf/vstf/common/candy_text.py
new file mode 100755
index 00000000..818ae767
--- /dev/null
+++ b/vstf/vstf/common/candy_text.py
@@ -0,0 +1,61 @@
+##############################################################################
+# Copyright (c) 2015 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+
+import sys
+
+THIS = sys.modules[__name__]
+__id_max = 100
+__style_max = 10
+dom = {"chapter", "section", "unit"}
+element = {"title", "table", "figure", "paragraph", "plot", "chart", "space"}
+
+nodes = dom | element
+for _node in nodes:
+ setattr(THIS, _node, _node)
+
+
+def tuple2text(sn, node, style):
+ assert sn in range(__id_max)
+ assert style in range(__style_max)
+ assert node in nodes
+ return "%02d##%s#%d" % (sn, node, style)
+
+
+def dict2text(info):
+ assert "sn" in info and info["sn"] in range(__id_max)
+ assert "style" in info and info["style"] in range(__style_max)
+ assert "node" in info and info["node"] in nodes
+ return "%02d##%s#%d" % (info["sn"], info["node"], info["style"])
+
+
+def text2dict(candy):
+ tmp = candy.replace("##","#").split("#")
+ result = {
+ "sn": int(tmp[0]),
+ "node": tmp[1],
+ "style": int(tmp[2])
+ }
+ assert result["sn"] in range(__id_max)
+ assert result["style"] in range(__style_max)
+ assert result["node"] in nodes
+ return result
+
+
+def text2tuple(candy):
+ tmp = candy.replace("##","#").split("#")
+
+ sn = int(tmp[0])
+ node = tmp[1]
+ style = int(tmp[2])
+
+ assert sn in range(__id_max)
+ assert style in range(__style_max)
+ assert node in nodes
+ return sn, node, style