/usr/share/pyshared/pygraphviz/tests/unicode.txt is in python-pygraphviz 1.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 | # -*- coding: utf-8 -*-
>>> from pygraphviz import *
>>> A = AGraph(name=u'unicode')
>>> print A
strict graph unicode {
}
<BLANKLINE>
# node encoding
>>> A = AGraph(encoding='UTF-8')
>>> hello='Здравствуйте!'.decode('UTF-8')
>>> A.add_node(hello)
>>> n=A.get_node(hello)
>>> n.name==hello
True
>>> unicode(A)
u'strict graph {\n\tgraph [encoding="UTF-8"];\n\t"\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435!";\n}\n'
# set node attribute
>>> n.attr['goodbye']="До свидания".decode('UTF-8')
>>> n.attr
{u'goodbye': u'\u0414\u043e \u0441\u0432\u0438\u0434\u0430\u043d\u0438\u044f'}
>>> n.attr['goodbye']=="До свидания".decode('UTF-8')
True
# edge encoding
>>> A = AGraph(encoding='UTF-8')
>>> hello="שלום".decode('UTF-8')
>>> A.add_edge(hello,hello,key=1) # self loop
>>> e=A.get_edge(hello,hello)
>>> e.name
u'1'
>>> e==(hello,hello)
True
>>> unicode(A)
u'strict graph {\n\tgraph [encoding="UTF-8"];\n\t\u05e9\u05dc\u05d5\u05dd -- \u05e9\u05dc\u05d5\u05dd [key=1];\n}\n'
# set edge attribute
>>> e.attr['hello']=hello
>>> e.attr['hello']==hello
True
>>> e.attr
{u'hello': u'\u05e9\u05dc\u05d5\u05dd'}
# test unicode in from_string()
>>> t = u'测试'
>>> G =AGraph()
>>> G.add_node(t)
>>> ug = unicode(G)
>>> sg = str(G)
>>> G1 = AGraph(ug)
>>> G2 = AGraph(sg)
>>> unicode(G1)
u'strict graph {\n\t\xe6\xb5\x8b\xe8\xaf\x95;\n}\n'
>>> unicode(G2)
u'strict graph {\n\t\xe6\xb5\x8b\xe8\xaf\x95;\n}\n'
|