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
d23a2e21
Commit
d23a2e21
authored
Mar 20, 2014
by
Tiago Peixoto
Browse files
Don't ignore output parameter in graph_draw() when inline == True
parent
4bc34c3b
Changes
1
Show whitespace changes
Inline
Side-by-side
src/graph_tool/draw/cairo_draw.py
View file @
d23a2e21
...
...
@@ -169,6 +169,18 @@ def open_file(name, mode="r"):
fmt
=
os
.
path
.
splitext
(
name
)[
1
].
replace
(
"."
,
""
)
return
out
,
fmt
def
get_file_fmt
(
name
):
name
=
os
.
path
.
expanduser
(
name
)
base
,
ext
=
os
.
path
.
splitext
(
name
)
if
ext
==
".gz"
:
name
=
base
elif
ext
==
".bz2"
:
name
=
base
elif
ext
==
".zip"
:
name
=
base
fmt
=
os
.
path
.
splitext
(
name
)[
1
].
replace
(
"."
,
""
)
return
fmt
def
surface_from_prop
(
surface
):
if
isinstance
(
surface
,
PropertyMap
):
...
...
@@ -835,7 +847,11 @@ def graph_draw(g, pos=None, vprops=None, eprops=None, vorder=None, eorder=None,
if
inline
:
if
fmt
==
"auto"
:
if
output
is
None
:
fmt
=
"png"
else
:
fmt
=
get_file_fmt
(
output
)
output_file
=
output
output
=
io
.
BytesIO
()
if
output
is
None
:
...
...
@@ -915,6 +931,15 @@ def graph_draw(g, pos=None, vprops=None, eprops=None, vorder=None, eorder=None,
img
=
IPython
.
display
.
SVG
(
data
=
out
.
getvalue
())
if
img
is
None
:
raise
ValueError
(
"Invalid format for inline drawing: "
+
fmt
)
if
output_file
is
not
None
:
if
isinstance
(
output_file
,
str
):
ofile
,
auto_fmt
=
open_file
(
output_file
,
mode
=
"wb"
)
else
:
ofile
=
output_file
ofile
.
write
(
out
.
getvalue
())
if
isinstance
(
output_file
,
str
):
ofile
.
close
()
return
img
return
pos
...
...
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