Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Tiago Peixoto
graph-tool
Commits
d529c67e
Commit
d529c67e
authored
Oct 16, 2014
by
Tiago Peixoto
Browse files
Improve display of property maps
parent
26f7d07b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/graph_tool/__init__.py
View file @
d529c67e
...
...
@@ -109,6 +109,7 @@ import re
import
gzip
import
weakref
import
copy
import
textwrap
from
io
import
BytesIO
,
StringIO
from
.decorators
import
_wraps
,
_require
,
_attrs
,
_limit_args
...
...
@@ -252,6 +253,13 @@ def show_config():
print
(
"openmp:"
,
libcore
.
openmp_enabled
())
print
(
"uname:"
,
" "
.
join
(
os
.
uname
()))
def
terminal_size
():
import
fcntl
,
termios
,
struct
h
,
w
,
hp
,
wp
=
struct
.
unpack
(
'HHHH'
,
fcntl
.
ioctl
(
0
,
termios
.
TIOCGWINSZ
,
struct
.
pack
(
'HHHH'
,
0
,
0
,
0
,
0
)))
return
w
,
h
################################################################################
# Property Maps
################################################################################
...
...
@@ -443,8 +451,13 @@ class PropertyMap(object):
g
=
"a non-existent graph"
else
:
g
=
"Graph 0x%x"
%
id
(
g
)
try
:
vals
=
", with values:
\n
%s"
%
str
(
self
.
fa
)
except
ValueError
:
vals
=
""
return
(
"<PropertyMap object with key type '%s' and value type '%s',"
+
" for %s, at 0x%x>"
)
%
(
k
,
self
.
value_type
(),
g
,
id
(
self
))
+
" for %s, at 0x%x%s>"
)
%
(
k
,
self
.
value_type
(),
g
,
id
(
self
),
vals
)
def
copy
(
self
,
value_type
=
None
):
"""Return a copy of the property map. If ``value_type`` is specified,
...
...
@@ -1628,8 +1641,17 @@ class Graph(object):
for
k
,
v
in
self
.
__properties
.
items
():
if
k
[
0
]
==
"g"
:
print
(
"%%-%ds (graph) (type: %%s, val: %%s)"
%
w
%
\
(
k
[
1
],
v
.
value_type
(),
str
(
v
[
self
])))
pref
=
"%%-%ds (graph) (type: %%s, val: "
%
w
%
\
(
k
[
1
],
v
.
value_type
())
val
=
str
(
v
[
self
])
if
len
(
val
)
>
1000
:
val
=
val
[:
1000
]
+
"..."
tw
=
terminal_size
()[
0
]
val
=
textwrap
.
indent
(
textwrap
.
fill
(
val
,
width
=
max
(
tw
-
len
(
pref
),
1
)),
" "
*
len
(
pref
))
val
=
val
[
len
(
pref
):]
print
(
"%s%s)"
%
(
pref
,
val
))
for
k
,
v
in
self
.
__properties
.
items
():
if
k
[
0
]
==
"v"
:
print
(
"%%-%ds (vertex) (type: %%s)"
%
w
%
(
k
[
1
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment